Files
lisglosips/apps/api/src/main.ts
T

39 lines
988 B
TypeScript

import 'reflect-metadata';
import helmet from '@fastify/helmet';
import { NestFactory } from '@nestjs/core';
import { FastifyAdapter, type NestFastifyApplication } from '@nestjs/platform-fastify';
import { Logger } from 'nestjs-pino';
import { AppModule } from './modules/app.module.js';
import { buildOpenApiDocument } from './openapi.js';
async function bootstrap(): Promise<void> {
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter({
trustProxy: true,
logger: false,
routerOptions: {
maxParamLength: 256
}
}),
{
bufferLogs: true
}
);
app.useLogger(app.get(Logger));
app.setGlobalPrefix('api/v2');
await app.register(helmet, {
contentSecurityPolicy: false
});
buildOpenApiDocument(app);
const host = process.env.LISGLOSIPS_HOST ?? '127.0.0.1';
const port = Number(process.env.LISGLOSIPS_PORT ?? 3000);
await app.listen({ host, port });
}
void bootstrap();