@@ -9,9 +9,13 @@ import { BackendConfigService } from './backend-config.service';
99import { ActionType } from './_enum/action-type.enum' ;
1010import { ExecutorConfigInterface } from '~/_common/interfaces/executor-config.interface' ;
1111import Redis from 'ioredis' ;
12+ import { DumpPackageConfigExecutor } from './_executors/dump-package-config.executor' ;
13+ import { PackageJson } from 'types-package-json' ;
14+ import { readFileSync } from 'node:fs' ;
1215
1316@Injectable ( )
1417export class BackendRunnerService implements OnApplicationBootstrap , OnModuleInit {
18+ protected _package : Partial < PackageJson > ;
1519 private readonly _logger = new Logger ( BackendRunnerService . name ) ;
1620
1721 protected executors : Map < string , ExecutorInterface > = new Map < string , ExecutorInterface > ( ) ;
@@ -24,6 +28,10 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
2428 return this . _logger ;
2529 }
2630
31+ public get packageJson ( ) : Partial < PackageJson > {
32+ return this . _package ;
33+ }
34+
2735 public get backendExecutorConfig ( ) : ExecutorConfigInterface {
2836 return this . _config . get < ExecutorConfigInterface > ( 'application.backendExecutorConfig' ) ;
2937 }
@@ -32,11 +40,14 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
3240 private readonly _config : ConfigService ,
3341 private readonly _backendsConfig : BackendConfigService ,
3442 @InjectRedis ( ) private readonly redis : Redis ,
35- ) { }
43+ ) {
44+ this . _package = JSON . parse ( readFileSync ( 'package.json' , 'utf-8' ) ) ;
45+ }
3646
3747 public async onModuleInit ( ) {
3848 this . executors . set ( '*' , new CatchAllExecutor ( this ) ) ;
3949 this . executors . set ( ActionType . LIST_BACKENDS , new ListBackendsExecutor ( this ) ) ;
50+ this . executors . set ( ActionType . DUMP_PACKAGE_CONFIG , new DumpPackageConfigExecutor ( this ) ) ;
4051
4152 this . redis . on ( 'connecting' , ( ) => this . logger . verbose ( `Redis connecting... 🟡` ) ) ;
4253 this . redis . on ( 'connect' , ( ) => this . logger . log ( `Redis connected 🟢` ) ) ;
0 commit comments