Skip to content

Commit

Permalink
chore: added correct service name for api and cli services
Browse files Browse the repository at this point in the history
  • Loading branch information
bobalazek committed Oct 14, 2024
1 parent 6231988 commit 1e98fe1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
13 changes: 12 additions & 1 deletion apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
12 changes: 12 additions & 0 deletions apps/cli/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1e98fe1

Please sign in to comment.