import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import * as cookieParser from 'cookie-parser'; import { ConfigService } from '@nestjs/config'; import { ValidationPipe } from '@nestjs/common'; import { AllExceptionsFilter } from './filter/exceptions.filter'; async function bootstrap() { const app = await NestFactory.create(AppModule); // 开启全局验证 const configService = app.get(ConfigService); const port = configService.get('PORT'); app.use(cookieParser()); app.useGlobalPipes(new ValidationPipe()); app.useGlobalFilters(new AllExceptionsFilter()); app.setGlobalPrefix('cert'); await app.listen(port); // 控制输出项目的全部接口 const router = app.getHttpServer()._events.request._router; const routerList = router.stack .map((item) => ({ name: item.route?.path, methodType: item.route?.stack[0].method, })) .filter((i) => !!i.name && !!i.methodType); console.log(routerList); } bootstrap();