0afcf237e8
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { ValidationPipe } from '@nestjs/common';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { NestFactory } from '@nestjs/core';
|
|
import cookieParser from 'cookie-parser';
|
|
import { AppModule } from './app.module';
|
|
import { requestLogMiddleware } from './common/request-log';
|
|
import { formatAppVersionLine } from './health/app-version';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
const configService = app.get(ConfigService);
|
|
|
|
// Eine Zeile je Anfrage im Docker-Log (Pfad, Status, Dauer, Benutzer)
|
|
app.use(requestLogMiddleware);
|
|
|
|
// Cookie parser for JWT httpOnly cookies
|
|
app.use(cookieParser());
|
|
|
|
// Global validation pipe with whitelist and transform
|
|
app.useGlobalPipes(
|
|
new ValidationPipe({
|
|
whitelist: true,
|
|
transform: true,
|
|
}),
|
|
);
|
|
|
|
// CORS with credentials for cross-origin cookie support (Pitfall 4)
|
|
const corsOrigin = configService.get<string>('CORS_ORIGIN', 'http://localhost:3000');
|
|
app.enableCors({
|
|
origin: corsOrigin,
|
|
credentials: true,
|
|
});
|
|
|
|
await app.listen(3001);
|
|
console.log('Tessera API running on port 3001');
|
|
console.log(formatAppVersionLine());
|
|
}
|
|
|
|
bootstrap();
|