import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { HttpService } from '@nestjs/common'; import { logger } from './logger/logger.service'; import { Constants } from './utils/constants'; import { DataAccessService } from './data_access/dataAccess.service'; import { Check } from './check/utils'; async function bootstrap() { const app = await NestFactory.create(AppModule); const port = process.env.PORT || 3000; app.enableCors({ origin: '*', methods: ['GET', 'POST'], maxAge: 60, }); if (await Check.checkInternet(app.get(HttpService))) { if (Check.checkNeededFiles([`src/rules/${Constants.rulesExtension}`])) { await app.get(DataAccessService).connect(); await app.listen(port); } } else { logger.error('No internet connection'); } } bootstrap().catch(err => logger.error(err));