2021-11-25 15:14:15 +01:00
|
|
|
import { LogLevel } from '@nestjs/common';
|
2021-09-06 17:10:06 +02:00
|
|
|
import { NestFactory } from '@nestjs/core';
|
|
|
|
import { AppModule } from './app.module';
|
|
|
|
|
2021-11-25 15:14:15 +01:00
|
|
|
function isLogLevel(value: any): value is LogLevel {
|
|
|
|
return value in ['log', 'error', 'warn', 'debug', 'verbose'];
|
|
|
|
}
|
|
|
|
|
2021-09-06 17:10:06 +02:00
|
|
|
async function bootstrap() {
|
2021-11-25 15:14:15 +01:00
|
|
|
const logLevel = isLogLevel(process.env.LOG_LEVEL)
|
|
|
|
? process.env.LOG_LEVEL
|
2021-11-26 19:35:45 +01:00
|
|
|
: 'log';
|
2021-11-25 15:14:15 +01:00
|
|
|
|
2021-09-06 21:55:38 +02:00
|
|
|
const app = await NestFactory.create(AppModule, {
|
|
|
|
cors: true,
|
2021-11-25 15:14:15 +01:00
|
|
|
logger: [logLevel],
|
2021-09-06 21:55:38 +02:00
|
|
|
});
|
2021-11-25 15:14:15 +01:00
|
|
|
|
2021-09-08 17:17:39 +02:00
|
|
|
app.setGlobalPrefix(process.env.GLOBAL_PREFIX ?? '/api/v2');
|
2021-09-06 21:55:38 +02:00
|
|
|
|
2021-09-08 17:17:39 +02:00
|
|
|
await app.listen(process.env.PORT ?? 8080);
|
2021-09-06 17:10:06 +02:00
|
|
|
}
|
|
|
|
bootstrap();
|