Skip to content

Commit 948ee12

Browse files
authored
Merge pull request #15 from pct-org/improvements
Improvements
2 parents 130a981 + e69f4b6 commit 948ee12

File tree

11 files changed

+220
-191
lines changed

11 files changed

+220
-191
lines changed

.github/workflows/release.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Conventional Changelog Action
16+
uses: TriPSs/conventional-changelog-action@v3
17+
id: changelog
18+
with:
19+
github-token: ${{ secrets.github_token }}
20+
21+
- name: Create Release
22+
uses: actions/create-release@v1
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.github_token }}
25+
with:
26+
tag_name: ${{ steps.changelog.outputs.tag }}
27+
release_name: ${{ steps.changelog.outputs.tag }}
28+
body: ${{ steps.changelog.outputs.clean_changelog }}

apps/api/src/shared/config/config.service.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { LogLevel } from '@nestjs/common'
22
import * as Joi from '@hapi/joi'
3+
import { version } from '@pct-org/version'
34

45
export interface EnvConfig {
56
[key: string]: string;
@@ -38,6 +39,10 @@ export class ConfigService {
3839
return this.envConfig[key] || ''
3940
}
4041

42+
get version(): string {
43+
return version
44+
}
45+
4146
/**
4247
* Get the correct formatted database uri
4348
*/
@@ -114,10 +119,13 @@ export class ConfigService {
114119
.default(1),
115120

116121
[ConfigService.MAX_CONNS]: Joi.number()
117-
.default(35),
122+
.default(35)
118123
})
119124

120-
const { error, value: validatedEnvConfig } = envVarsSchema.validate(envConfig, { stripUnknown: true })
125+
const {
126+
error,
127+
value: validatedEnvConfig
128+
} = envVarsSchema.validate(envConfig, { stripUnknown: true })
121129

122130
if (error) {
123131
throw new Error(`Config validation error: ${error.message}`)

apps/api/src/status/status.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class StatusService {
4141
const sizePercentage = parseFloat((((disk.total - disk.available - folderSize) / disk.total) * 100).toFixed(2))
4242

4343
return {
44-
version: 'unknown', // TODO:: Get git tag
44+
version: this.configService.version,
4545
totalMovies: await this.movieModel.countDocuments(),
4646
totalShows: await this.showModel.countDocuments(),
4747
totalEpisodes: await this.episodesModel.countDocuments(),

apps/api/src/watch/watch.controller.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ export class WatchController {
135135
torrent.file.createReadStream(streamOptions)
136136
}
137137

138-
const readStream = fs.createReadStream(mediaFile, streamOptions)
139-
140-
res.send(readStream)
138+
res.send(fs.createReadStream(mediaFile, streamOptions))
141139
}
142140

143141
}

apps/scraper/src/routes/status/status.controller.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ import { Controller, Get, Inject, OnApplicationBootstrap } from '@nestjs/common'
22
import { SchedulerRegistry } from '@nestjs/schedule'
33
import { formatMsToRemaining } from '@pct-org/torrent/utils'
44

5+
import { ConfigService } from '../../shared/config/config.service'
6+
57
@Controller()
68
export class StatusController implements OnApplicationBootstrap {
79

810
@Inject()
911
private schedulerRegistry: SchedulerRegistry
1012

13+
@Inject()
14+
private configService: ConfigService
15+
1116
private bootedSince: number
1217

1318
public onApplicationBootstrap(): void {
@@ -20,7 +25,7 @@ export class StatusController implements OnApplicationBootstrap {
2025

2126
return {
2227
status: 'ok',
23-
version: 'beta',
28+
version: this.configService.version,
2429
updated: cron.lastDate() || 'never',
2530
nextUpdate: cron.nextDates(),
2631
uptime: formatMsToRemaining(Date.now() - this.bootedSince)

apps/scraper/src/shared/config/config.service.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { LogLevel } from '@nestjs/common'
22
import * as Joi from '@hapi/joi'
3+
import { version } from '@pct-org/version'
34

45
export interface EnvConfig {
56
[key: string]: string;
@@ -37,6 +38,10 @@ export class ConfigService {
3738
return this.envConfig[key] || ''
3839
}
3940

41+
get version(): string {
42+
return version
43+
}
44+
4045
/**
4146
* Get the correct formatted database uri
4247
*/
@@ -102,8 +107,7 @@ export class ConfigService {
102107
[ConfigService.TMDB_KEY]: Joi.string()
103108
.required(),
104109

105-
[ConfigService.TVDB_KEY]: Joi.string()
106-
.required(),
110+
[ConfigService.TVDB_KEY]: Joi.string(),
107111

108112
[ConfigService.OMDB_KEY]: Joi.string()
109113
.required(),
@@ -114,7 +118,10 @@ export class ConfigService {
114118
[ConfigService.SCRAPE_ON_START]: Joi.boolean()
115119
})
116120

117-
const { error, value: validatedEnvConfig } = envVarsSchema.validate(envConfig, { stripUnknown: true })
121+
const {
122+
error,
123+
value: validatedEnvConfig
124+
} = envVarsSchema.validate(envConfig, { stripUnknown: true })
118125

119126
if (error) {
120127
throw new Error(`Config validation error: ${error.message}`)

ecosystem.config.example.js

+2-19
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ module.exports = {
6060
error_file: `${logsDir}/api/error.log`,
6161
out_file: `${logsDir}/api/out.log`,
6262
log_file: null,
63-
env: sharedEnv
63+
env: sharedEnv,
6464
},
6565
{
6666
name: 'Scraper',
6767
script: 'dist/apps/scraper/main.js',
68-
args: '-m pretty',
68+
node_args: '--max-old-space-size=3072',
6969
instances: 1,
7070
max_restarts: 5,
7171
autorestart: true,
@@ -83,22 +83,5 @@ module.exports = {
8383
TEMP_DIR: `${logsDir}/`,
8484
},
8585
},
86-
// Enable this if you want auto updates
87-
// {
88-
// name: 'Updater',
89-
// cwd: 'updater',
90-
// script: 'dist/updater.js',
91-
// instances: 1,
92-
// max_restarts: 5,
93-
// autorestart: true,
94-
// watch: false,
95-
// error_file: `${logsDir}/updater.log`,
96-
// out_file: `${logsDir}/updater.log`,
97-
// log_file: null,
98-
// env: {
99-
// // The time between cronjobs.
100-
// CRON_TIME: '0 0 * * *',
101-
// },
102-
// },
10386
],
10487
}

install-scripts/ubuntu-server.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ set -e
44
echo "Installing essential tools..."
55
sudo apt-get install -y \
66
git \
7-
curl
8-
9-
sudo apt install build-essential
7+
curl \
8+
build-essential
109

1110
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
1211
export NVM_DIR="$HOME/.nvm"
@@ -32,7 +31,7 @@ sudo systemctl status mongod
3231
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
3332
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
3433

35-
sudo apt-get update && sudo apt-get install yarn
34+
sudo apt-get update && sudo apt-get install yarn -y
3635

3736
echo "Create directory..."
3837
sudo mkdir -p /pct-org

package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"dependencies": {
5151
"@hapi/joi": "17.1.1",
5252
"@nestjs/cli": "7.5.4",
53-
"@nestjs/common": "7.6.1",
54-
"@nestjs/core": "7.6.1",
53+
"@nestjs/common": "7.6.4",
54+
"@nestjs/core": "7.6.4",
5555
"@nestjs/graphql": "^7.7.0",
5656
"@nestjs/mongoose": "7.2.0",
5757
"@nestjs/platform-fastify": "7.0.9",
@@ -79,7 +79,7 @@
7979
"opensubtitles-api": "^5.1.2",
8080
"p-map": "^4.0.0",
8181
"p-times": "^3.0.0",
82-
"pm2": "^4.5.0",
82+
"pm2": "^4.5.1",
8383
"reflect-metadata": "^0.1.12",
8484
"rimraf": "3.0.2",
8585
"rxjs": "6.6.3",
@@ -94,22 +94,22 @@
9494
},
9595
"devDependencies": {
9696
"@nestjs/schematics": "^7.2.5",
97-
"@nestjs/testing": "^7.6.1",
98-
"@nrwl/eslint-plugin-nx": "11.0.4",
99-
"@nrwl/jest": "11.0.4",
100-
"@nrwl/nest": "^11.0.4",
101-
"@nrwl/node": "11.0.4",
102-
"@nrwl/workspace": "11.0.4",
97+
"@nestjs/testing": "^7.6.4",
98+
"@nrwl/eslint-plugin-nx": "11.0.16",
99+
"@nrwl/jest": "11.0.16",
100+
"@nrwl/nest": "^11.0.16",
101+
"@nrwl/node": "11.0.16",
102+
"@nrwl/workspace": "11.0.16",
103103
"@types/cheerio": "^0.22.23",
104104
"@types/jest": "26.0.19",
105105
"@types/mongoose": "^5.10.3",
106-
"@types/node": "~14.14.13",
106+
"@types/node": "~14.14.14",
107107
"@types/webtorrent": "^0.109.0",
108-
"@typescript-eslint/eslint-plugin": "4.10.0",
109-
"@typescript-eslint/parser": "4.10.0",
108+
"@typescript-eslint/eslint-plugin": "4.11.0",
109+
"@typescript-eslint/parser": "4.11.0",
110110
"dotenv": "6.2.0",
111-
"eslint": "7.15.0",
112-
"eslint-config-prettier": "7.0.0",
111+
"eslint": "7.16.0",
112+
"eslint-config-prettier": "7.1.0",
113113
"jest": "26.6.3",
114114
"prettier": "2.2.1",
115115
"ts-jest": "26.4.4",

tsconfig.base.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
"@pct-org/types/shared": ["libs/types/shared/src/index.ts"],
6464
"@pct-org/types/blacklist": ["libs/types/blacklist/src/index.ts"],
6565
"@pct-org/types/download": ["libs/types/download/src/index.ts"],
66-
"@pct-org/types/image": ["libs/types/image/src/index.ts"]
66+
"@pct-org/types/image": ["libs/types/image/src/index.ts"],
67+
"@pct-org/version": ["./package.json"]
6768
}
6869
},
6970
"exclude": ["node_modules", "tmp"]

0 commit comments

Comments
 (0)