- add HttpExceptionFilter logging BadRequestException at warn and InternalServerErrorException at error with cause chain
- add LoggingInterceptor logging request/response pairs at debug level with method, path, body, status, and duration
- extract CodeExecutorService into standalone CodeExecutorModule imported by BrowserModule and McpModule
- thread { cause: err } into all catch blocks across auth, browser, and code-executor services
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { Logger, ValidationPipe } from '@nestjs/common';
|
|
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
import { AppModule } from './app.module';
|
|
import { HttpExceptionFilter } from './filters/http-exception.filter';
|
|
import { LoggingInterceptor } from './interceptors/logging.interceptor';
|
|
import { name as pkgName, version as pkgVersion } from '../package.json';
|
|
|
|
async function bootstrap() {
|
|
const logger = new Logger('Bootstrap');
|
|
const app = await NestFactory.create(AppModule);
|
|
|
|
app.useGlobalPipes(new ValidationPipe({ transform: true }));
|
|
app.useGlobalFilters(new HttpExceptionFilter());
|
|
app.useGlobalInterceptors(new LoggingInterceptor());
|
|
|
|
const config = app.get(ConfigService);
|
|
const port = config.get<number>('PORT', 3000);
|
|
const nodeEnv = config.get<string>('NODE_ENV', 'development');
|
|
|
|
const swaggerConfig = new DocumentBuilder()
|
|
.setTitle(pkgName)
|
|
.setDescription(`${pkgName} API`)
|
|
.setVersion(pkgVersion)
|
|
.build();
|
|
|
|
const document = SwaggerModule.createDocument(app, swaggerConfig);
|
|
SwaggerModule.setup('api', app, document);
|
|
|
|
await app.listen(port);
|
|
|
|
logger.log(`Application "${pkgName}" v${pkgVersion} running on port ${port} [${nodeEnv}]`);
|
|
logger.log(`Swagger UI available at http://localhost:${port}/api`);
|
|
logger.log(`MCP endpoint available at http://localhost:${port}/mcp`);
|
|
}
|
|
|
|
bootstrap();
|