/
voting
/
voting-backend
Обзор
Документация
Войти
/
voting
/
voting-backend
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
main
src/main.ts
35 строк
1011 B
TimPulin
018-add-swagger
17 июл 2026, 21:36
17 июл 2026, 21:36
b094eae
Код
Авторство
О чём код?
import { RequestMethod, ValidationPipe } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { NestFactory } from '@nestjs/core' import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger' import { AppModule } from './app.module' async function bootstrap() { const app = await NestFactory.create(AppModule) app.setGlobalPrefix('api/v1', { exclude: [{ path: '/', method: RequestMethod.GET }] }) app.useGlobalPipes( new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true }) ) const swaggerConfig = new DocumentBuilder() .setTitle('Voting Backend API') .setDescription('REST API for the voting application') .setVersion('1.0') .build() const document = SwaggerModule.createDocument(app, swaggerConfig) SwaggerModule.setup('api/docs', app, document) const configService = app.get(ConfigService) const port = configService.get<number>('PORT', 3000) await app.listen(port) } bootstrap()