1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
import { ValidationPipe } from '@nestjs/common'; import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { HttpExceptionFilter } from './filters/http-exception.filter'; import { TransformInterceptor } from './interceptor/transform.interceptor'; import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
async function bootstrap() { const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe()) app.useGlobalInterceptors(new TransformInterceptor()) app.useGlobalFilters(new HttpExceptionFilter())
const options = new DocumentBuilder() .setTitle('blog-serve') .setDescription('接口文档') .setVersion('1.0') .build(); const document = SwaggerModule.createDocument(app, options); SwaggerModule.setup('swagger-doc', app, document);
await app.listen(3000); } bootstrap();
|