diff --git a/apps/api/src/shared/config/config.service.ts b/apps/api/src/shared/config/config.service.ts index c8a0a2c..227ffdd 100644 --- a/apps/api/src/shared/config/config.service.ts +++ b/apps/api/src/shared/config/config.service.ts @@ -1,5 +1,6 @@ import { LogLevel } from '@nestjs/common' import * as Joi from '@hapi/joi' +import { version } from '@pct-org/version' export interface EnvConfig { [key: string]: string; @@ -38,6 +39,10 @@ export class ConfigService { return this.envConfig[key] || '' } + get version(): string { + return version + } + /** * Get the correct formatted database uri */ @@ -114,10 +119,13 @@ export class ConfigService { .default(1), [ConfigService.MAX_CONNS]: Joi.number() - .default(35), + .default(35) }) - const { error, value: validatedEnvConfig } = envVarsSchema.validate(envConfig, { stripUnknown: true }) + const { + error, + value: validatedEnvConfig + } = envVarsSchema.validate(envConfig, { stripUnknown: true }) if (error) { throw new Error(`Config validation error: ${error.message}`) diff --git a/apps/api/src/status/status.service.ts b/apps/api/src/status/status.service.ts index 223c828..f36bcec 100755 --- a/apps/api/src/status/status.service.ts +++ b/apps/api/src/status/status.service.ts @@ -41,7 +41,7 @@ export class StatusService { const sizePercentage = parseFloat((((disk.total - disk.available - folderSize) / disk.total) * 100).toFixed(2)) return { - version: 'unknown', // TODO:: Get git tag + version: this.configService.version, totalMovies: await this.movieModel.countDocuments(), totalShows: await this.showModel.countDocuments(), totalEpisodes: await this.episodesModel.countDocuments(), diff --git a/apps/scraper/src/routes/status/status.controller.ts b/apps/scraper/src/routes/status/status.controller.ts index 8ec990e..6aa1f57 100644 --- a/apps/scraper/src/routes/status/status.controller.ts +++ b/apps/scraper/src/routes/status/status.controller.ts @@ -2,12 +2,17 @@ import { Controller, Get, Inject, OnApplicationBootstrap } from '@nestjs/common' import { SchedulerRegistry } from '@nestjs/schedule' import { formatMsToRemaining } from '@pct-org/torrent/utils' +import { ConfigService } from '../../shared/config/config.service' + @Controller() export class StatusController implements OnApplicationBootstrap { @Inject() private schedulerRegistry: SchedulerRegistry + @Inject() + private configService: ConfigService + private bootedSince: number public onApplicationBootstrap(): void { @@ -20,7 +25,7 @@ export class StatusController implements OnApplicationBootstrap { return { status: 'ok', - version: 'beta', + version: this.configService.version, updated: cron.lastDate() || 'never', nextUpdate: cron.nextDates(), uptime: formatMsToRemaining(Date.now() - this.bootedSince) diff --git a/apps/scraper/src/shared/config/config.service.ts b/apps/scraper/src/shared/config/config.service.ts index c47972c..2545ca3 100644 --- a/apps/scraper/src/shared/config/config.service.ts +++ b/apps/scraper/src/shared/config/config.service.ts @@ -1,5 +1,6 @@ import { LogLevel } from '@nestjs/common' import * as Joi from '@hapi/joi' +import { version } from '@pct-org/version' export interface EnvConfig { [key: string]: string; @@ -37,6 +38,10 @@ export class ConfigService { return this.envConfig[key] || '' } + get version(): string { + return version + } + /** * Get the correct formatted database uri */ @@ -113,7 +118,10 @@ export class ConfigService { [ConfigService.SCRAPE_ON_START]: Joi.boolean() }) - const { error, value: validatedEnvConfig } = envVarsSchema.validate(envConfig, { stripUnknown: true }) + const { + error, + value: validatedEnvConfig + } = envVarsSchema.validate(envConfig, { stripUnknown: true }) if (error) { throw new Error(`Config validation error: ${error.message}`) diff --git a/tsconfig.base.json b/tsconfig.base.json index f1a856f..6a7e493 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -63,7 +63,8 @@ "@pct-org/types/shared": ["libs/types/shared/src/index.ts"], "@pct-org/types/blacklist": ["libs/types/blacklist/src/index.ts"], "@pct-org/types/download": ["libs/types/download/src/index.ts"], - "@pct-org/types/image": ["libs/types/image/src/index.ts"] + "@pct-org/types/image": ["libs/types/image/src/index.ts"], + "@pct-org/version": ["./package.json"] } }, "exclude": ["node_modules", "tmp"]