Skip to content

Commit 085f851

Browse files
committed
chore: Updated deps
1 parent e830d5f commit 085f851

28 files changed

+1713
-847
lines changed

Diff for: apps/api/src/app.module.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Module } from '@nestjs/common'
22
import { GraphQLModule } from '@nestjs/graphql'
3-
import { MongooseModule } from '@nestjs/mongoose'
3+
import { ApolloDriver } from '@nestjs/apollo'
4+
import { MongooseModule, MongooseModuleOptions } from '@nestjs/mongoose'
45

56
import { ModelsModule } from './shared/models.module'
67
import { ConfigModule } from './shared/config/config.module'
@@ -54,24 +55,22 @@ import { WatchModule } from './watch/watch.module'
5455
imports: [ConfigModule],
5556
inject: [ConfigService],
5657
useFactory: (configService: ConfigService) => ({
57-
uri: configService.databaseUri,
58-
useNewUrlParser: true,
59-
useUnifiedTopology: true,
60-
useFindAndModify: false
58+
uri: configService.databaseUri
6159
})
6260
}),
6361

6462
// Enable Graphql
6563
GraphQLModule.forRootAsync({
6664
imports: [ConfigModule],
6765
inject: [ConfigService],
66+
driver: ApolloDriver,
6867
useFactory: (configService: ConfigService) => ({
6968
debug: configService.isDevelopment,
7069
tracing: configService.isDevelopment,
7170
playground: true,
7271
installSubscriptionHandlers: true,
7372
autoSchemaFile: 'schema.gql',
74-
introspection: true,
73+
introspection: true
7574
})
7675
})
7776
]

Diff for: apps/api/src/bookmarks/bookmarks.service.ts

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import { Injectable } from '@nestjs/common'
22
import { InjectModel } from '@nestjs/mongoose'
3-
import { MovieModel, MOVIES_TYPE } from '@pct-org/types/movie'
4-
import { ShowModel, SHOWS_TYPE } from '@pct-org/types/show'
3+
import { MovieDocument, MOVIES_TYPE } from '@pct-org/types/movie'
4+
import { ShowDocument, SHOWS_TYPE } from '@pct-org/types/show'
55
import { Content } from '@pct-org/types/shared'
66

7+
import type { Model } from 'mongoose'
8+
79
import { BookmarksArgs } from './dto/bookmarks.args'
810
import { NewBookmarkInput } from './dto/new-bookmark.input'
911

1012
@Injectable()
1113
export class BookmarksService {
1214

1315
@InjectModel('Movies')
14-
private readonly movieModel: MovieModel
16+
private readonly movieModel: Model<MovieDocument>
1517

1618
@InjectModel('Shows')
17-
private readonly showModel: ShowModel
19+
private readonly showModel: Model<ShowDocument>
1820

1921
public async findAll(bookmarksArgs: BookmarksArgs): Promise<Content[]> {
2022
const movies = ['none', MOVIES_TYPE].includes(bookmarksArgs.filter)
@@ -65,24 +67,24 @@ export class BookmarksService {
6567
* @param {boolean} add - Do we need to add or remove the bookmark
6668
*/
6769
public async updateBookmark(addBookmarksArgs: NewBookmarkInput, add: boolean): Promise<Content> {
68-
return (
69-
addBookmarksArgs.type === 'movie'
70-
? this.movieModel
71-
: this.showModel
70+
const update = {
71+
bookmarked: add,
72+
bookmarkedOn: add
73+
? Number(new Date())
74+
: null
75+
}
7276

73-
).findByIdAndUpdate(
74-
addBookmarksArgs._id,
75-
{
76-
bookmarked: add,
77-
bookmarkedOn: add
78-
? Number(new Date())
79-
: null
80-
},
81-
{
82-
new: true, // Return the new updated object
83-
lean: true
84-
}
85-
)
77+
const options = {
78+
new: true, // Return the new updated object
79+
lean: true
80+
}
81+
82+
if (addBookmarksArgs.type === 'movie') {
83+
return this.movieModel.findByIdAndUpdate(addBookmarksArgs._id, update, options)
84+
85+
} else {
86+
return this.showModel.findByIdAndUpdate(addBookmarksArgs._id, update, options)
87+
}
8688
}
8789

8890
/**
@@ -101,7 +103,9 @@ export class BookmarksService {
101103
bookmarked: true,
102104
title: {
103105
// Update the query to make it better searchable
104-
$regex: bookmarksArgs.query.trim().split(' ').join('.+'),
106+
$regex: bookmarksArgs.query.trim()
107+
.split(' ')
108+
.join('.+'),
105109
$options: 'i'
106110
}
107111
}

Diff for: apps/api/src/bookmarks/bookmarks.union.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ export const BookmarksUnion = createUnionType({
77
types: () => [Movie, Show],
88
resolveType(value) {
99
if (value.type === MOVIE_TYPE) {
10-
return Movie
10+
return 'Movie'
1111
}
1212

1313
if (value.type === SHOW_TYPE) {
14-
return Show
14+
return 'Show'
1515
}
1616

1717
return null

Diff for: apps/api/src/downloads/downloads.service.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { Injectable } from '@nestjs/common'
22
import { InjectModel } from '@nestjs/mongoose'
3-
import { Download, DownloadModel } from '@pct-org/types/download'
3+
import { Download, DownloadDocument } from '@pct-org/types/download'
44
import { EPISODE_TYPE } from '@pct-org/types/episode'
55

6+
import type { Model } from 'mongoose'
7+
68
import { DownloadsArgs } from './dto/downloads.args'
79
import { NewDownloadInput } from './dto/new-download.input'
810
import { TorrentService } from '../shared/torrent/torrent.service'
@@ -11,7 +13,7 @@ import { TorrentService } from '../shared/torrent/torrent.service'
1113
export class DownloadsService {
1214

1315
@InjectModel('Downloads')
14-
private readonly downloadModel: DownloadModel
16+
private readonly downloadModel: Model<DownloadDocument>
1517

1618
/**
1719
* Add's one download

Diff for: apps/api/src/shared/models.module.ts

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Global, Module } from '@nestjs/common'
2-
3-
import { MOVIES_MONGOOSE_FEATURE } from '@pct-org/types/movie'
4-
import { SHOWS_MONGOOSE_FEATURE } from '@pct-org/types/show'
2+
import { MongooseModule } from '@nestjs/mongoose'
3+
import { movieSchema } from '@pct-org/types/movie'
4+
import { showSchema } from '@pct-org/types/show'
55
import { SEASONS_MONGOOSE_FEATURE } from '@pct-org/types/season'
66
import { EPISODES_MONGOOSE_FEATURE } from '@pct-org/types/episode'
77
import { DOWNLOADS_MONGOOSE_FEATURE } from '@pct-org/types/download'
@@ -10,20 +10,28 @@ import { BLACKLIST_MONGOOSE_FEATURE } from '@pct-org/types/blacklist'
1010
@Global()
1111
@Module({
1212
imports: [
13-
MOVIES_MONGOOSE_FEATURE,
14-
SHOWS_MONGOOSE_FEATURE,
13+
14+
// TODO:: Refactor the models to decorators
15+
// https://docs.nestjs.com/techniques/mongodb#model-injection
16+
MongooseModule.forFeature([
17+
{
18+
name: 'Movies',
19+
schema: movieSchema
20+
},
21+
{
22+
name: 'Shows',
23+
schema: showSchema
24+
}
25+
]
26+
),
27+
1528
SEASONS_MONGOOSE_FEATURE,
1629
EPISODES_MONGOOSE_FEATURE,
1730
DOWNLOADS_MONGOOSE_FEATURE,
1831
BLACKLIST_MONGOOSE_FEATURE
1932
],
2033
exports: [
21-
MOVIES_MONGOOSE_FEATURE,
22-
SHOWS_MONGOOSE_FEATURE,
23-
SEASONS_MONGOOSE_FEATURE,
24-
EPISODES_MONGOOSE_FEATURE,
25-
DOWNLOADS_MONGOOSE_FEATURE,
26-
BLACKLIST_MONGOOSE_FEATURE
34+
MongooseModule
2735
]
2836
})
2937
export class ModelsModule {

Diff for: apps/api/src/shared/movie-episode.union.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export const MovieEpisodeUnion = createUnionType({
88
types: () => [Movie, Episode],
99
resolveType(value) {
1010
if (value.type === MOVIE_TYPE) {
11-
return Movie
11+
return 'Movie'
1212

1313
} else if (value.type === EPISODE_TYPE) {
14-
return Episode
14+
return 'Episode'
1515
}
1616

1717
return null

Diff for: apps/api/src/shared/subtitles/subtitles.service.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import { Injectable, Logger } from '@nestjs/common'
22
import { HttpService } from '@nestjs/axios'
33
import { InjectModel } from '@nestjs/mongoose'
4-
import { Download, DownloadModel } from '@pct-org/types/download'
4+
import { Download, DownloadDocument } from '@pct-org/types/download'
55
import { TorrentFile } from 'webtorrent'
66
import OpenSubtitles from 'opensubtitles-api'
77
import { createWriteStream, existsSync } from 'fs'
88
import { resolve } from 'path'
99

10+
import type { Model } from 'mongoose'
11+
1012
import { ConfigService } from '../config/config.service'
1113
import { SubtitleInterface } from './subtitle.interface'
1214

1315
@Injectable()
1416
export class SubtitlesService {
17+
1518
private readonly logger = new Logger(SubtitlesService.name)
1619

1720
private readonly client: OpenSubtitles
@@ -21,7 +24,7 @@ export class SubtitlesService {
2124
private readonly supportedLanguages: string[]
2225

2326
@InjectModel('Downloads')
24-
private readonly downloadModel: DownloadModel
27+
private readonly downloadModel: Model<DownloadDocument>
2528

2629
constructor(
2730
private readonly httpService: HttpService,

Diff for: apps/api/src/shared/torrent/torrent.service.ts

+18-13
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import { formatBytes, formatMsToRemaining } from '@pct-org/torrent/utils'
77
import * as rimraf from 'rimraf'
88
import { Movie, MoviesService, MOVIE_TYPE } from '@pct-org/types/movie'
99
import { Episode, EpisodesService } from '@pct-org/types/episode'
10-
import { Download, DownloadModel } from '@pct-org/types/download'
10+
import { Download, DownloadDocument } from '@pct-org/types/download'
1111
import { DownloadInfo } from '@pct-org/types/shared'
1212

13-
import {
14-
TorrentInterface,
15-
ConnectingTorrentInterface
16-
} from './torrent.interface'
13+
import type { Model } from 'mongoose'
14+
15+
import { TorrentInterface, ConnectingTorrentInterface } from './torrent.interface'
1716
import { ConfigService } from '../config/config.service'
1817
import { SubtitlesService } from '../subtitles/subtitles.service'
1918

@@ -100,7 +99,7 @@ export class TorrentService implements OnApplicationBootstrap {
10099
private webTorrent: WebTorrentInstance = null
101100

102101
@InjectModel('Downloads')
103-
private readonly downloadModel: DownloadModel
102+
private readonly downloadModel: Model<DownloadDocument>
104103

105104
constructor(
106105
private readonly configService: ConfigService,
@@ -353,7 +352,10 @@ export class TorrentService implements OnApplicationBootstrap {
353352

354353
const item = await this.getItemForDownload(download)
355354

356-
const { torrents, searchedTorrents } = item
355+
const {
356+
torrents,
357+
searchedTorrents
358+
} = item
357359

358360
// Find the correct magnet
359361
const magnet =
@@ -435,7 +437,10 @@ export class TorrentService implements OnApplicationBootstrap {
435437

436438
return previous
437439
},
438-
{ file: torrent.files[0], torrentIndex: 0 }
440+
{
441+
file: torrent.files[0],
442+
torrentIndex: 0
443+
}
439444
)
440445

441446
// Select this file to be the main
@@ -460,7 +465,7 @@ export class TorrentService implements OnApplicationBootstrap {
460465
// Keep track if we are currently updating the model, prevents updating same item twice at the same time
461466
let updatingModel = false
462467

463-
torrent.on('error', async (err) => {
468+
torrent.on('error', async(err) => {
464469
const error = err instanceof Error ? err.message : err
465470
this.logger.error(`[${download._id}]: Torrent error`, error)
466471

@@ -476,7 +481,7 @@ export class TorrentService implements OnApplicationBootstrap {
476481
resolve()
477482
})
478483

479-
torrent.on('noPeers', async (announceType) => {
484+
torrent.on('noPeers', async(announceType) => {
480485
this.logger.warn(
481486
`[${download._id}]: No peers found, announce type: ${announceType}`
482487
)
@@ -502,7 +507,7 @@ export class TorrentService implements OnApplicationBootstrap {
502507
resolve()
503508
})
504509

505-
torrent.on('download', async () => {
510+
torrent.on('download', async() => {
506511
const newProgress = torrent.progress * 100
507512
const newFileProgress = file.progress * 100
508513

@@ -556,7 +561,7 @@ export class TorrentService implements OnApplicationBootstrap {
556561
}
557562
})
558563

559-
torrent.on('done', async () => {
564+
torrent.on('done', async() => {
560565
this.logger.log(`[${download._id}]: Download complete`)
561566

562567
// Remove the magnet from the client
@@ -580,7 +585,7 @@ export class TorrentService implements OnApplicationBootstrap {
580585

581586
// Wait at-least 0,5 second before updating, this is to prevent
582587
// a double save happening
583-
setTimeout(async () => {
588+
setTimeout(async() => {
584589
await this.updateDownload(download, {
585590
progress: 100,
586591
status: TorrentService.STATUS_COMPLETE,

Diff for: apps/api/src/status/status.service.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { HttpService } from '@nestjs/axios'
33
import { InjectModel } from '@nestjs/mongoose'
44
import { checkSync } from 'diskusage'
55
import { formatBytes } from '@pct-org/torrent/utils'
6-
import { MovieModel } from '@pct-org/types/movie'
7-
import { ShowModel } from '@pct-org/types/show'
8-
import { EpisodeModel } from '@pct-org/types/episode'
6+
import { MovieDocument } from '@pct-org/types/movie'
7+
import { ShowDocument } from '@pct-org/types/show'
8+
import { EpisodeDocument } from '@pct-org/types/episode'
99
import fastFolderSizeSync from 'fast-folder-size/sync'
1010

11+
import type { Model } from 'mongoose'
12+
1113
import { Status } from './status.object-type'
1214
import { StatusScraper } from './status-scraper.object-type'
1315
import { ConfigService } from '../shared/config/config.service'
@@ -16,13 +18,13 @@ import { ConfigService } from '../shared/config/config.service'
1618
export class StatusService {
1719

1820
@InjectModel('Movies')
19-
private readonly movieModel: MovieModel
21+
private readonly movieModel: Model<MovieDocument>
2022

2123
@InjectModel('Shows')
22-
private readonly showModel: ShowModel
24+
private readonly showModel: Model<ShowDocument>
2325

2426
@InjectModel('Episodes')
25-
private readonly episodesModel: EpisodeModel
27+
private readonly episodesModel: Model<EpisodeDocument>
2628

2729
@Inject()
2830
private readonly configService: ConfigService

Diff for: apps/rest-api/src/app.module.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ import { ShowsModule } from './routes/shows/shows.module'
2222
imports: [ConfigModule],
2323
inject: [ConfigService],
2424
useFactory: (configService: ConfigService) => ({
25-
uri: configService.databaseUri,
26-
useNewUrlParser: true,
27-
useUnifiedTopology: true,
28-
useFindAndModify: false
25+
uri: configService.databaseUri
2926
})
3027
})
3128
]

Diff for: apps/scraper/src/scraper.module.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ import { StatusModule } from './routes/status/status.module'
2525
imports: [ConfigModule],
2626
inject: [ConfigService],
2727
useFactory: (configService: ConfigService) => ({
28-
uri: configService.databaseUri,
29-
useNewUrlParser: true,
30-
useUnifiedTopology: true,
31-
useFindAndModify: false
28+
uri: configService.databaseUri
3229
})
3330
}),
3431

0 commit comments

Comments
 (0)