feat: Phase 1 – Plattform-Grundgerüst (Docker, NestJS, React, Auth)

This commit is contained in:
MPM Dev
2026-10-06 14:22:11 +02:00
commit a7e1c421f2
85 changed files with 17701 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import cookieParser from 'cookie-parser';
import helmet from 'helmet';
import { AppModule } from './app.module';
import { AllExceptionsFilter } from './common/filters/all-exceptions.filter';
import { loadConfiguration } from './config/config.tokens';
/**
* Bootstrap der Management-API:
* - Security-Header (Helmet), Trust-Proxy für korrekte IPs
* - OpenAPI/Swagger unter /api/docs
* - Strukturierte Fehlerbehandlung
* Hinweis: Validierung erfolgt über Zod (ZodValidationPipe),
* nicht über den NestJS-ValidationPipe (class-validator).
*/
async function bootstrap(): Promise<void> {
const config = loadConfiguration();
const logger = new Logger('Bootstrap');
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
logger: config.nodeEnv === 'production' ? ['log', 'warn', 'error'] : ['log', 'warn', 'error', 'debug'],
});
app.use(helmet());
app.use(cookieParser());
if (config.security.behindProxy) {
app.set('trust proxy', 1);
}
app.useGlobalFilters(new AllExceptionsFilter());
const swaggerConfig = new DocumentBuilder()
.setTitle('MPM Management API')
.setDescription('Zentrale Management-API der MPM-Plattform (Auth, RBAC, Health)')
.setVersion('0.1.0')
.addCookieAuth('mpm_session')
.build();
const document = SwaggerModule.createDocument(app, swaggerConfig);
SwaggerModule.setup('api/docs', app, document);
await app.listen(config.port, '0.0.0.0');
logger.log(`Management-Backend läuft auf Port ${config.port}`);
}
void bootstrap();