Skip to content
This repository was archived by the owner on Mar 2, 2025. It is now read-only.

Commit

Permalink
fix: disable pino-pretty for non-development env
Browse files Browse the repository at this point in the history
  • Loading branch information
IKatsuba committed Sep 22, 2023
1 parent 8dbfb38 commit 08b7cb7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions apps/api/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ DB_PASSWORD=postgres
DB_NAME=postgres

PORT=3000

ENV=development
15 changes: 8 additions & 7 deletions apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ import { PrometheusStatsModule } from '@nx-turbo/api-stats';
useFactory: (configService: ConfigService<Environment>) => ({
pinoHttp: {
level: configService.get('LOG_LEVEL', 'info'),
transport: environment.production
? undefined
: {
target: 'pino-pretty',
options: {
colorize: true,
transport:
environment.production || configService.get('ENV') !== 'development'
? undefined
: {
target: 'pino-pretty',
options: {
colorize: true,
},
},
},
},
}),
inject: [ConfigService],
Expand Down
2 changes: 2 additions & 0 deletions libs/api/models/src/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ export interface Environment {
// LOG starts here
LOG_LEVEL: LevelWithSilent;
// LOG ends here

ENV: 'development' | string;
}
8 changes: 7 additions & 1 deletion scripts/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ import { Logger } from 'nestjs-pino';

app.useLogger(logger);

logger.log('Starting migrations...');

const orm = app.get(MikroORM);

const migrator = orm.getMigrator();
await migrator.createMigration();
await migrator.up();

logger.log('Migrations finished.');

await orm.close(true);
})();
})().catch((e) => {
console.error(e);
});

0 comments on commit 08b7cb7

Please sign in to comment.