| 1 | import { NestFactory } from '@nestjs/core'; |
| 2 | import { AppModule } |
| 3 | import { SwaggerModule } |
| 4 | import { apiReference } |
| 5 | import { ValidationPipe } |
| 6 | import { DomainErrorFilter } |
| 7 | import { openApiConfig } |
| 8 | import { GIT_TRANSPORT_ROUTES } |
| 9 | import morgan from 'morgan |
| 10 | |
| 11 | async function bootstrap() |
| 12 | const app = |
| 13 | bodyParser: false, |
| 14 | }); |
| 15 | app.enableShutdownHooks(); |
| 16 | app.useGlobalPipes(new |
| 17 | app.use(morgan |
| 18 | app.useGlobalFilters(new |
| 19 | // offset all CRUD apis to /api prefix so it does not conflict with git's rest stuff |
| 20 | app.setGlobalPrefix('/api |
| 21 | |
| 22 | const document = |
| 23 | app.use( |
| 24 | '/reference', |
| 25 | apiReference({ content: |
| 26 | ); |
| 27 | |
| 28 | app.enableCors({ |
| 29 | origin: (process.env |
| 30 | .split(',') |
| 31 | .map((origin) |
| 32 | .filter(Boolean), |
| 33 | credentials: true, |
| 34 | }); |
| 35 | // Railway (and most PaaS) inject PORT; API_PORT stays for local dev. |
| 36 | await app.listen |
| 37 | } |
| 38 | await bootstrap(); |