-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
main.hmr.ts
executable file
·59 lines (53 loc) · 1.82 KB
/
main.hmr.ts
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { FastifyAdapter, NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { ConfigService } from './config';
import * as helmet from 'helmet';
import { environment as env } from '@env-api/environment';
declare const module: any;
async function bootstrap() {
// const app = await NestFactory.create(AppModule, new FastifyAdapter(), { cors: true });
const app = await NestFactory.create(AppModule, { cors: true });
const config: ConfigService = app.get(ConfigService);
app.use(helmet());
app.useGlobalPipes(
new ValidationPipe({
transform: true,
whitelist: true,
forbidNonWhitelisted: true,
skipMissingProperties: false,
forbidUnknownValues: true,
}),
);
const options = new DocumentBuilder()
.setTitle('Sumo API Docs')
.setDescription('Sumo API for Ngx Starter Kit')
.setExternalDoc('Github Repo', 'https://github.com/xmlking/ngx-starter-kit/tree/master/apps/api')
.setVersion(config.getVersion())
.addTag('Sumo')
.addTag('External')
.setSchemes(config.isProd() ? 'https' : 'http')
.addOAuth2(
'implicit',
`${env.oidc.issuerUrl}/protocol/openid-connect/auth`,
`${env.oidc.issuerUrl}/protocol/openid-connect/token`,
)
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('docs', app, document, {
swaggerOptions: {
oauth2RedirectUrl: `${env.server.domainUrl})}/docs/oauth2-redirect.html`,
oauth: {
clientId: env.oidc.client,
appName: 'Sumo API',
},
},
});
await app.listen(env.server.port || 3000, '0.0.0.0');
if (module.hot) {
module.hot.accept();
module.hot.dispose(() => app.close());
}
}
bootstrap();