Added swagger and config read

This commit is contained in:
2023-11-18 02:00:33 +03:00
parent 841e9955bf
commit dd33571463
3 changed files with 37 additions and 2 deletions

View File

@@ -1,8 +1,14 @@
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { config } from 'config';
import { AppModule } from './app.module';
import { swagger } from './swagger';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
const app = await NestFactory.create(AppModule, {
logger: ['log', 'debug', 'error', 'warn', 'verbose'],
});
swagger(app);
await app.listen(config.server.port, () => Logger.log(`Server started on port ${config.server.port}`));
}
bootstrap();

9
backend/src/swagger.ts Normal file
View File

@@ -0,0 +1,9 @@
import { INestApplication } from '@nestjs/common';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
export function swagger(app: INestApplication): INestApplication {
const config = new DocumentBuilder().setTitle('Neuro website').setDescription('Some description').setVersion('0.1').build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);
return app;
}