MCPcopy
hub / github.com/ever-co/ever-demand / bootstrapNest

Function bootstrapNest

packages/core/src/nest-bootstrap.ts:19–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17declare const module: any;
18
19export async function bootstrapNest(): Promise<void> {
20
21 const app: INestApplication = await NestFactory.create(ApplicationModule, {
22 logger: new EverbieNestJSLogger(),
23 });
24
25 // This will lock all routes and make them accessible by authenticated users only.
26 const reflector = app.get(Reflector);
27 // app.useGlobalGuards(new AuthGuard(reflector));
28
29 // app.useLogger(app.get(SentryService));
30 app.use(json({ limit: '50mb' }));
31 app.use(urlencoded({ extended: true, limit: '50mb' }));
32
33 app.enableCors({
34 origin: '*',
35 methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
36 credentials: true,
37 allowedHeaders:
38 'Authorization, Language, Tenant-Id, X-Requested-With, X-Auth-Token, X-HTTP-Method-Override, Content-Type, Content-Language, Accept, Accept-Language, Observe'
39 });
40
41 // TODO: enable csurf
42 // As explained on the csurf middleware page https://github.com/expressjs/csurf#csurf,
43 // the csurf module requires either a session middleware or cookie-parser to be initialized first.
44 // app.use(csurf());
45
46 app.use(
47 expressSession({
48 secret: env.EXPRESS_SESSION_SECRET,
49 resave: true,
50 saveUninitialized: true
51 })
52 );
53
54 app.use(helmet());
55 const globalPrefix = 'api';
56 app.setGlobalPrefix(globalPrefix);
57
58 const options = new DocumentBuilder()
59 .setTitle('Ever Demand REST API')
60 .setVersion('1.0')
61 .addBearerAuth()
62 .build();
63
64 const document = SwaggerModule.createDocument(app, options);
65 SwaggerModule.setup('swg', app, document);
66
67 const port: number = env.GQLPORT;
68 let host: string = env.API_HOST;
69
70 if (!host) {
71 host = '0.0.0.0';
72 }
73
74 console.log(chalk.green(`Configured Host: ${host}`));
75 console.log(chalk.green(`Configured Port: ${port}`));
76

Callers 1

main.tsFile · 0.85

Calls 7

buildMethod · 0.80
setupMethod · 0.80
logMethod · 0.80
listenMethod · 0.80
createMethod · 0.65
getMethod · 0.65
closeMethod · 0.45

Tested by

no test coverage detected