Backend security / security (push) Successful in 8s
Backend verify / verify (push) Successful in 11m9s
Conventional commits / commits (pull_request) Successful in 28s
Backend security / security (pull_request) Successful in 7s
Backend verify / verify (pull_request) Successful in 10m38s
Resolve A01-A10 and C01-C07 from the backend audit. Preserve auth failures, forced candle reconciliation and forecast freshness. Validate MOEX responses and nested HTTP errors; remove unused legacy paths. Verified: 209 unit tests, 262 SQLite e2e tests on Linux, OpenAPI and durability. Record the remaining macOS native SQLite abort in the audit.
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import {
|
|
BadRequestException,
|
|
INestApplication,
|
|
ValidationPipe,
|
|
} from '@nestjs/common';
|
|
import { NestFactory } from '@nestjs/core';
|
|
import cookieParser from 'cookie-parser';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { SwaggerModule } from '@nestjs/swagger';
|
|
import { API_PREFIX, createOpenApiDocument } from './openapi';
|
|
import { Logger } from 'nestjs-pino';
|
|
import { AppModule } from './app.module';
|
|
import { HttpExceptionFilter } from './common/filters/http-exception.filter';
|
|
import { RequestLoggingMiddleware } from './common/logging/request-logging.middleware';
|
|
import { StructuredLogger } from './common/logging/structured-logger.service';
|
|
import { Environment } from './config/env.validation';
|
|
import { shouldExposeSwagger } from './config/swagger.config';
|
|
|
|
export function configureApp(app: INestApplication): void {
|
|
const config = app.get<ConfigService<Environment, true>>(ConfigService);
|
|
const frontendOrigin = config.getOrThrow<string>('FRONTEND_ORIGIN');
|
|
|
|
app.useLogger(app.get(Logger));
|
|
app.enableCors({
|
|
origin: frontendOrigin,
|
|
credentials: true,
|
|
exposedHeaders: ['X-Request-ID'],
|
|
});
|
|
app.setGlobalPrefix(API_PREFIX);
|
|
app.use(cookieParser());
|
|
const requestLogging = app.get(RequestLoggingMiddleware);
|
|
app.use(requestLogging.use.bind(requestLogging));
|
|
app.useGlobalPipes(
|
|
new ValidationPipe({
|
|
transform: true,
|
|
whitelist: true,
|
|
validationError: { target: false, value: false },
|
|
exceptionFactory: (message) => new BadRequestException({ message }),
|
|
}),
|
|
);
|
|
app.useGlobalFilters(new HttpExceptionFilter());
|
|
app.enableShutdownHooks();
|
|
}
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule, { bufferLogs: true });
|
|
configureApp(app);
|
|
const config = app.get<ConfigService<Environment, true>>(ConfigService);
|
|
|
|
if (shouldExposeSwagger(process.env['NODE_ENV'])) {
|
|
const document = createOpenApiDocument(app);
|
|
SwaggerModule.setup('api/docs', app, document);
|
|
}
|
|
|
|
await app.listen(config.getOrThrow('PORT'));
|
|
app.get(StructuredLogger).info('application.started', {
|
|
service: 'wealth-ledger-backend',
|
|
environment: process.env['NODE_ENV'] ?? 'development',
|
|
});
|
|
}
|
|
if (require.main === module) void bootstrap();
|