Skip to content

Commit e69f4b6

Browse files
committed
feat: Use version from package.json
1 parent 9a21d7b commit e69f4b6

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

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/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

+9-1
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
*/
@@ -113,7 +118,10 @@ export class ConfigService {
113118
[ConfigService.SCRAPE_ON_START]: Joi.boolean()
114119
})
115120

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

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

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)