|
3 | 3 | import path from 'node:path'; |
4 | 4 |
|
5 | 5 | import { ValidationPipe } from '@douglasneuroinformatics/libnest/core'; |
6 | | -import { type LogLevel, VersioningType } from '@nestjs/common'; |
| 6 | +import { JSONLogger } from '@douglasneuroinformatics/libnest/logging'; |
| 7 | +import { VersioningType } from '@nestjs/common'; |
7 | 8 | import { NestFactory } from '@nestjs/core'; |
8 | | -import { type NestExpressApplication } from '@nestjs/platform-express'; |
| 9 | +import type { NestExpressApplication } from '@nestjs/platform-express'; |
9 | 10 | import { json } from 'express'; |
10 | 11 |
|
11 | 12 | import { AppModule } from './app.module'; |
12 | 13 | import { ConfigurationService } from './configuration/configuration.service'; |
13 | 14 | import { setupDocs } from './docs'; |
14 | 15 |
|
15 | 16 | async function bootstrap() { |
16 | | - // This hacky type assertion is needed due to issue with linked dependency |
17 | | - const app = (await NestFactory.create(AppModule)) as any as NestExpressApplication; |
| 17 | + const app = await NestFactory.create<NestExpressApplication>(AppModule, { |
| 18 | + logger: false |
| 19 | + }); |
18 | 20 | app.enableShutdownHooks(); |
19 | 21 |
|
20 | 22 | const configurationService = app.get(ConfigurationService); |
21 | | - const logLevels: LogLevel[] = ['error', 'fatal', 'log', 'warn']; |
22 | | - if (configurationService.get('DEBUG')) { |
23 | | - console.log("Enabled 'debug' logs"); |
24 | | - logLevels.push('debug'); |
25 | | - } |
26 | | - if (configurationService.get('VERBOSE')) { |
27 | | - console.log("Enabled 'verbose' logs"); |
28 | | - logLevels.push('verbose'); |
29 | | - } |
30 | | - |
31 | | - console.log({ debug: configurationService.get('DEBUG') }); |
32 | | - |
33 | | - app.useLogger(logLevels); |
| 23 | + |
| 24 | + app.useLogger( |
| 25 | + new JSONLogger(null, { |
| 26 | + debug: configurationService.get('DEBUG'), |
| 27 | + verbose: configurationService.get('VERBOSE') |
| 28 | + }) |
| 29 | + ); |
34 | 30 |
|
35 | 31 | app.enableCors(); |
36 | 32 | app.enableVersioning({ |
|
0 commit comments