-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.ts
37 lines (31 loc) · 1.04 KB
/
main.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
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import {
SwaggerModule,
DocumentBuilder,
SwaggerDocumentOptions,
} from '@nestjs/swagger';
import * as fs from 'fs';
/** Setup the application
*/
async function bootstrap() {
const app = await NestFactory.create(AppModule, { cors: true });
// Setup the swagger documentation
const config = new DocumentBuilder()
.setTitle('Bonfire Backend API')
.setDescription('Project for CSCC01')
.setVersion('1.0.0')
.addBearerAuth({ in: 'header', type: 'http' })
.build();
const options: SwaggerDocumentOptions = {
operationIdFactory: (controllerKey: string, methodKey: string) => methodKey,
};
if (process.env.NODE_ENV !== 'production') {
const document = SwaggerModule.createDocument(app, config, options);
SwaggerModule.setup('api-docs', app, document);
fs.writeFileSync('./swagger-spec.json', JSON.stringify(document, null, 2));
}
// Start the application
await app.listen(process.env.PORT || 3000);
}
bootstrap();