From 1e98fe1b4025b10f155d18eb394bb58d3b2adbac Mon Sep 17 00:00:00 2001 From: Borut Balazek Date: Mon, 14 Oct 2024 18:39:47 +0200 Subject: [PATCH] chore: added correct service name for api and cli services --- apps/api/src/main.ts | 13 ++++++++++++- apps/cli/package.json | 1 + apps/cli/src/main.ts | 12 ++++++++++++ pnpm-lock.yaml | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 5faafdc1..a4d946b0 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -3,7 +3,8 @@ import { NestFactory } from '@nestjs/core'; import { WsAdapter } from '@nestjs/platform-ws'; import { json } from 'express'; -import { getEnv } from '@moaitime/shared-backend'; +import { logger } from '@moaitime/logging'; +import { getEnv, setEnv } from '@moaitime/shared-backend'; import { AppModule } from './app.module'; import { ErrorFilter } from './filters/error.filter'; @@ -16,6 +17,16 @@ declare const module: any; export async function bootstrap() { Logger.log('🚀 Starting the API server...'); + setEnv({ + SERVICE_NAME: 'api', + }); + + logger.reset({ + base: { + service: 'api', + }, + }); + // Variables const { API_PORT, NODE_ENV } = getEnv(); const port = API_PORT || 3636; diff --git a/apps/cli/package.json b/apps/cli/package.json index 2ce400f9..57351479 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -26,6 +26,7 @@ "@moaitime/job-runner": "workspace:*", "@moaitime/logging": "workspace:*", "@moaitime/processes": "workspace:*", + "@moaitime/shared-backend": "workspace:*", "commander": "^11.1.0", "tsx": "^4.19.1" } diff --git a/apps/cli/src/main.ts b/apps/cli/src/main.ts index d4cf5713..8272132b 100644 --- a/apps/cli/src/main.ts +++ b/apps/cli/src/main.ts @@ -2,6 +2,7 @@ import { Command } from 'commander'; import { destroyDatabase } from '@moaitime/database-core'; import { logger } from '@moaitime/logging'; +import { setEnv } from '@moaitime/shared-backend'; import { addDatabaseBackupCommand } from './database/DatabaseBackupCommand'; import { addDatabaseFixturesInsertCommand } from './database/DatabaseFixturesInsertCommand'; @@ -35,6 +36,17 @@ addDatabaseReloadCommand(program); addJobsRunnerStartCommand(program); program + .hook('preAction', async () => { + setEnv({ + SERVICE_NAME: 'cli', + }); + + logger.reset({ + base: { + service: 'cli', + }, + }); + }) .hook('postAction', async () => { await destroyDatabase(); await logger.terminate(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5be7bbee..838b6d30 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -235,6 +235,9 @@ importers: '@moaitime/processes': specifier: workspace:* version: link:../../packages/processes + '@moaitime/shared-backend': + specifier: workspace:* + version: link:../../packages/shared-backend commander: specifier: ^11.1.0 version: 11.1.0