| 12345678910111213141516171819202122232425262728293031 |
- /**
- * 应用入口 - NestJS 引导,全局 /v1 前缀,端口从环境变量读取
- */
- import { NestFactory } from '@nestjs/core';
- import { ValidationPipe } from '@nestjs/common';
- import { AppModule } from './app.module';
- async function bootstrap() {
- const app = await NestFactory.create(AppModule);
- // 全局参数校验
- app.useGlobalPipes(
- new ValidationPipe({
- whitelist: true,
- forbidNonWhitelisted: true,
- transform: true,
- }),
- );
- // 全局 API 前缀
- app.setGlobalPrefix('v1');
- // CORS 开启(后续收紧)
- app.enableCors();
- const port = process.env['PORT'] ?? 8080;
- await app.listen(port);
- console.log(`🚀 DoTouch.AI API running on http://localhost:${port}/v1`);
- }
- void bootstrap();
|