mirror of
https://github.com/MrSedan/neuro-reply-website.git
synced 2026-01-14 20:49:42 +03:00
Added swagger and config read
This commit is contained in:
20
backend/config/index.ts
Normal file
20
backend/config/index.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { config as configInit } from 'dotenv';
|
||||||
|
|
||||||
|
configInit();
|
||||||
|
|
||||||
|
export const config = {
|
||||||
|
database: {
|
||||||
|
type: 'postgres',
|
||||||
|
host: process.env.DATABASE_HOST || 'localhost',
|
||||||
|
port: +process.env.DATABASE_PORT || 5432,
|
||||||
|
username: process.env.DATABASE_USERNAME || 'postgres',
|
||||||
|
password: process.env.DATABASE_PASSWORD || '',
|
||||||
|
database: process.env.DATABASE_DB || 'bot_db',
|
||||||
|
synchronize: true,
|
||||||
|
logging: false,
|
||||||
|
autoLoadEntities: true,
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
port: +process.env.SERVER_PORT || 8080,
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,8 +1,14 @@
|
|||||||
|
import { Logger } from '@nestjs/common';
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
import { config } from 'config';
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
|
import { swagger } from './swagger';
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule, {
|
||||||
await app.listen(3000);
|
logger: ['log', 'debug', 'error', 'warn', 'verbose'],
|
||||||
|
});
|
||||||
|
swagger(app);
|
||||||
|
await app.listen(config.server.port, () => Logger.log(`Server started on port ${config.server.port}`));
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
9
backend/src/swagger.ts
Normal file
9
backend/src/swagger.ts
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user