Repository navigation
Expand file tree
/
Copy pathmain.ts
More file actions
40 lines (35 loc) · 1.43 KB
/
Copy pathmain.ts
File metadata and controls
40 lines (35 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import 'reflect-metadata';
import { NestFactory } from '@nestjs/core';
import { ExpressAdapter } from '@nestjs/platform-express';
import { AppModule } from './src/app.module';
const config = require('config');
const expressApplication = require('./app');
const { checkMemberDatabaseHealth } = require('./src/common/memberDatabaseHealth');
const logger = require('./src/common/logger');
/**
* Bootstraps Member API v6 through NestJS using the compatibility Express app.
*
* Nest's automatic body parser is disabled because the established application
* already registers JSON, URL-encoded, file-upload, authentication, and error
* middleware in a behavior-sensitive order. The existing PORT environment
* variable remains the only listener configuration.
*
* Before accepting traffic, startup verifies and warms the same primary
* database connection used by the public health endpoint.
*
* @returns A promise that resolves after the HTTP server begins listening.
* @throws Propagates Nest creation, database warm-up, or listener failures.
*/
export async function bootstrap(): Promise<void> {
const adapter = new ExpressAdapter(expressApplication);
const app = await NestFactory.create(AppModule, adapter, {
bodyParser: false,
logger: false,
});
await checkMemberDatabaseHealth();
await app.listen(config.PORT);
logger.info(`NestJS server listening on port ${config.PORT}`);
}
if (require.main === module) {
void bootstrap();
}