Spaces:
Paused
Paused
Download apps/prevision-api/src/app.setup.ts from modventures/prevision: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/spaces/modventures/prevision/resolve/main/apps/prevision-api/src/app.setup.ts
- Command line
-
hf download hf://spaces/modventures/prevision/apps/prevision-api/src/app.setup.ts
-
curl -L -o app.setup.ts https://huggingface.co/spaces/modventures/prevision/resolve/main/apps/prevision-api/src/app.setup.ts
1.3 kB
| import { type INestApplication, RequestMethod, ValidationPipe } from '@nestjs/common'; | |
| import { HttpExceptionFilter } from './common/filters/http-exception.filter.js'; | |
| import { ResponseInterceptor } from './common/interceptors/response.interceptor.js'; | |
| import { APP_CONFIG, isOriginAllowed } from './config/app-config.js'; | |
| import type { AppConfig } from './config/app-config.interface.js'; | |
| /** Shared by main.ts and the e2e tests. */ | |
| export function setupApp(app: INestApplication): INestApplication { | |
| const config = app.get<AppConfig>(APP_CONFIG); | |
| app.setGlobalPrefix('api', { | |
| exclude: [ | |
| { path: 'health', method: RequestMethod.GET }, | |
| { path: 'ready', method: RequestMethod.GET }, | |
| { path: 'internal/{*path}', method: RequestMethod.ALL }, | |
| ], | |
| }); | |
| app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true, forbidNonWhitelisted: true })); | |
| app.useGlobalInterceptors(new ResponseInterceptor()); | |
| app.useGlobalFilters(new HttpExceptionFilter()); | |
| app.enableCors({ | |
| origin: (origin: string | undefined, done: (error: Error | null, allow?: boolean) => void) => | |
| done(null, !origin || isOriginAllowed(config, origin)), | |
| methods: ['GET', 'POST'], | |
| allowedHeaders: ['Authorization', 'Content-Type'], | |
| maxAge: 600, | |
| }); | |
| return app; | |
| } | |