Edit: /opt/mawid/apps/api/src/main.ts (1286B)
import { HttpAdapterHost, NestFactory } from '@nestjs/core';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import * as Sentry from '@sentry/node';
import { Logger } from 'nestjs-pino';
import { AppModule } from './app.module';
import { SentryExceptionFilter } from './common/sentry.filter';
async function bootstrap() {
if (process.env.SENTRY_DSN) {
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV ?? 'development',
});
}
// rawBody is required to validate Meta's X-Hub-Signature-256 webhook signatures.
const app = await NestFactory.create
(AppModule, new FastifyAdapter(), {
rawBody: true,
bufferLogs: true,
});
app.useLogger(app.get(Logger));
app.useGlobalFilters(new SentryExceptionFilter(app.get(HttpAdapterHost).httpAdapter));
// @fastify/cors only allows GET/HEAD/POST by default — list everything the
// dashboard uses so PATCH (status changes, settings) and DELETE preflight.
app.enableCors({
origin: process.env.DASHBOARD_BASE_URL ?? true,
methods: ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE'],
});
const port = Number(process.env.API_PORT ?? 3001);
await app.listen({ port, host: '0.0.0.0' });
}
void bootstrap();