added initial swagger docs
This commit is contained in:
parent
f72047b18e
commit
b7acc9e352
7 changed files with 80 additions and 16 deletions
13
src/main.ts
13
src/main.ts
|
|
@ -1,11 +1,20 @@
|
|||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
|
||||
async function bootstrap(): Promise<void> {
|
||||
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
||||
app.enableCors();
|
||||
app.setGlobalPrefix(process.env.PREFIX ?? 'common-cents');
|
||||
const appPrefix = process.env.PREFIX ?? 'common-cents';
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Common Cents API')
|
||||
.setDescription('Documentation for Common Cents API')
|
||||
.setVersion('1.0')
|
||||
.build();
|
||||
const documentFactory = () => SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup(appPrefix + '/docs', app, documentFactory);
|
||||
app.enableCors(); // TODO: Research if this is worth worrying about
|
||||
app.setGlobalPrefix(appPrefix);
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
}
|
||||
void bootstrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue