add more logs

This commit is contained in:
LeoMortari
2025-09-15 01:15:29 -03:00
parent 9b3675a10d
commit bbb6c97408
3 changed files with 96 additions and 34 deletions

View File

@@ -1,13 +1,44 @@
import { ClassSerializerInterceptor } from '@nestjs/common';
import {
ClassSerializerInterceptor,
Logger,
ValidationPipe,
} from '@nestjs/common';
import { NestFactory, Reflector } from '@nestjs/core';
import { AppModule } from './app.module';
import { Logger as PinoLogger } from 'nestjs-pino';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const app = await NestFactory.create(AppModule, {
bufferLogs: true,
logger: ['error', 'warn', 'log', 'debug', 'verbose'],
});
const reflector = app.get(Reflector);
const logger = new Logger('Bootstrap');
const pinoLogger = app.get(PinoLogger);
app.useLogger(pinoLogger);
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
transform: true,
}),
);
app.useGlobalInterceptors(new ClassSerializerInterceptor(reflector));
await app.listen(process.env.PORT ?? 3000);
app.enableCors();
const port = process.env.PORT ?? 3000;
await app.listen(port);
logger.log(`Application is running on port: ${port}`);
logger.debug(`Debug mode is enabled`);
}
void bootstrap();
bootstrap().catch((err) => {
const logger = new Logger('Bootstrap');
logger.error('Failed to start application', err);
process.exit(1);
});