Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
✨ Add OpenAPI docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Oct 27, 2020
1 parent e8e14c3 commit 754495e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import helmet from 'helmet';
import { AppModule } from './app.module';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { promises } from 'fs';
import { join } from 'path';

async function bootstrap() {
const app = await NestFactory.create(AppModule);

app.useGlobalPipes(new ValidationPipe());
app.use(helmet());

const pkg = JSON.parse(
await promises.readFile(join('.', 'package.json'), 'utf8'),
);

const options = new DocumentBuilder()
.setTitle('API')
.setDescription('API description')
.setVersion(pkg.version)
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);

await app.listen(3000);
}
bootstrap();

0 comments on commit 754495e

Please sign in to comment.