Skip to content

Commit

Permalink
refactor: removed datasource initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
aniebietafia committed Aug 31, 2024
1 parent 07518c8 commit 54fd711
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions brints-estate-api/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
import { NestFactory } from '@nestjs/core';
import { ConfigService } from '@nestjs/config';
import { Logger } from '@nestjs/common';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';

import { AppModule } from './app.module';
import { initializeDataSource } from './database/data-source';
import { swaggerInitializer } from './config/config.swagger';

async function bootstrap() {
await initializeDataSource();
const app = await NestFactory.create(AppModule);
const configService = new ConfigService();

const port = configService.get('APP_PORT');
const logger = new Logger();
const app = await NestFactory.create(AppModule);

/**
* Swagger configuration
*/
const config = new DocumentBuilder()
.setTitle('Brints Estate API')
.setDescription(
'The modern day Real Estate API simplifying the way we buy and sell properties',
)
.addServer('http://localhost:3001', 'Development Server')
.addServer('https://brints-estate-api.herokuapp.com', 'Production Server')
.setTermsOfService('http://localhost:3001/terms')
.setLicense(
'MIT',
'https://github.com/Brints/nestjs-brints-group-estate/blob/main/LICENSE',
)
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api-docs', app, document);
swaggerInitializer(app);

await app.listen(3001);
logger.log('Application started on http://localhost:3001');
await app.listen(port);
logger.log(`Application is running on ${await app.getUrl()}`);
}
bootstrap();

0 comments on commit 54fd711

Please sign in to comment.