| 1 | import { |
| 2 | type INestApplication, |
| 3 | RequestMethod, |
| 4 | ValidationPipe, |
| 5 | } from '@nestjs/common'; |
| 6 | import type { Express |
| 7 | |
| 8 | import { DomainErrorFilter } |
| 9 | import { GIT_TRANSPORT_ROUTES } |
| 10 | |
| 11 | export const OAUTH_ROUTES = |
| 12 | { path: 'login/device/code', |
| 13 | { path: 'login/oauth/access_token', |
| 14 | { path: 'login/oauth/authorize', |
| 15 | ]; |
| 16 | |
| 17 | /** What every running instance needs, shared by `main.ts` and the end-to-end suite so the two cannot drift. The app must be created with `bodyParser: false`. */ |
| 18 | export function configureApp(app |
| 19 | // Caddy and the web server reach the API over the private network, so only their X-Forwarded-For sets req.ip; a request straight to the published port keeps its own address. |
| 20 | const server: |
| 21 | server.set('trust proxy |
| 22 | // Node closes idle connections after 5s, the same as gh's device-flow poll interval, so a reused connection races the close and resets; outlast clients and proxies instead. |
| 23 | app.getHttpServer().keepAliveTimeout |
| 24 | app.useGlobalPipes(new |
| 25 | app.useGlobalFilters(new |
| 26 | // offset all CRUD apis to /api prefix so it does not conflict with git's rest stuff |
| 27 | app.setGlobalPrefix('/api |
| 28 | } |