/
istok
/
idp_server
Обзор
Документация
Войти
/
istok
/
idp_server
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
dev
apps/server/src/main.ts
62 строки
2 KB
ArtemAstakhov
Move client to nextjs
22 ноя 2025, 22:42
22 ноя 2025, 22:42
35e7508
Код
Авторство
О чём код?
import { ValidationPipe, VersioningType } from '@nestjs/common'; import { NestFactory } from '@nestjs/core'; import { NestExpressApplication } from '@nestjs/platform-express'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { ValidationError } from 'class-validator'; import * as cookieParser from 'cookie-parser'; import { Environment } from 'src/core/types/environment'; import { ConfigService } from 'src/infrastructure/config/config.service'; import { AppModule } from './app.module'; import { ExceptionFilter } from './core/errors/exception.filter'; import { ServerException } from './core/errors/server-exception'; async function bootstrap() { const app = await NestFactory.create<NestExpressApplication>(AppModule); const configService = app.get(ConfigService); app.enable('trust proxy'); app.enableCors(); app.use(cookieParser()); app.useGlobalFilters(new ExceptionFilter(app.getHttpAdapter())); app.enableVersioning({ type: VersioningType.URI, }); app.useGlobalPipes( new ValidationPipe({ transform: true, validationError: { target: true }, exceptionFactory: (validationErrors: ValidationError[] = []) => { return ServerException.fromValidationErrors(validationErrors); }, forbidUnknownValues: true, forbidNonWhitelisted: true, whitelist: true, stopAtFirstError: true, }), ); const port = configService.environment.port; const env = configService.environment.env; if (env !== Environment.Production) { const config = new DocumentBuilder() .setTitle('IDP Server API') .setDescription('Identity Provider Server API documentation') .setVersion('1.0') .addTag('Clients') .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); } await app.listen(port); } bootstrap();