19 lines
674 B
TypeScript
19 lines
674 B
TypeScript
import { NestFactory } from '@nestjs/core';
|
|||
|
|
import type { LogLevel } from '@nestjs/common';
|
||
|
|
import { AppModule } from './app.module.js';
|
||
|
|
import { AppConfigService } from './config/app-config.service.js';
|
||
|
|
|
||
|
|
const LOG_LEVELS: LogLevel[] = ['error', 'warn', 'log', 'debug', 'verbose'];
|
||
|
|
|
||
|
|
async function bootstrap() {
|
||
|
|
const app = await NestFactory.create(AppModule);
|
||
|
|
const config = app.get(AppConfigService);
|
||
|
|
|
||
|
|
app.setGlobalPrefix('api');
|
||
|
|
app.useLogger(LOG_LEVELS.slice(0, LOG_LEVELS.indexOf(config.get('LOG_LEVEL')) + 1));
|
||
|
|
app.enableCors({ origin: config.get('CORS_ORIGINS') });
|
||
|
|
app.enableShutdownHooks();
|
||
|
|
|
||
|
|
await app.listen(config.get('PORT'));
|
||
|
|
}
|
||
|
|
await bootstrap();
|