added initial swagger docs
This commit is contained in:
parent
f72047b18e
commit
b7acc9e352
7 changed files with 80 additions and 16 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { HealthcheckController } from './healthcheck.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { MerchantsModule } from './merchants/merchants.module';
|
||||
import { TagsModule } from './tags/tags.module';
|
||||
|
|
@ -40,6 +40,6 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
|
|||
SubCategoriesModule,
|
||||
ExpensesModule
|
||||
],
|
||||
controllers: [AppController]
|
||||
controllers: [HealthcheckController]
|
||||
})
|
||||
export class AppModule { }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Controller, Get } from '@nestjs/common';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
export class HealthcheckController {
|
||||
@Get('healthcheck')
|
||||
health() {
|
||||
return { status: 'healthy' };
|
||||
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