Files
IdP/apps/api-gateway/src/main.ts
2026-07-05 18:28:25 +03:00

40 lines
1.4 KiB
TypeScript

import { ValidationPipe } 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 { AppModule } from './app.module';
import { AllExceptionsFilter } from './grpc-exception.filter';
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.set('trust proxy', 1);
app.use(cookieParser());
app.enableCors({ origin: true, credentials: true });
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
transform: true,
forbidNonWhitelisted: true
})
);
app.useGlobalFilters(new AllExceptionsFilter());
const config = new DocumentBuilder()
.setTitle('Lendry ID API')
.setDescription('REST API для единого входа, безопасности, RBAC и администрирования.')
.setVersion('0.1.0')
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('docs', app, document, {
yamlDocumentUrl: '/openapi.yaml',
swaggerOptions: { persistAuthorization: true },
customSiteTitle: 'Документация API'
});
await app.listen(process.env.PORT ? Number(process.env.PORT) : 3000);
}
void bootstrap();