Files
fiberops-api/src/main.ts
kevin-asprec 59ee1fbe33 feat: add notification triggers, comment roles, mention list, and static file serving
- Notify users on ticket assignment and remittance confirm/reject
- Add collector role to comment endpoints
- Add /users/mention-list endpoint for @mention support
- Serve uploaded files via express.static
2026-05-06 14:30:08 +08:00

51 lines
1.4 KiB
TypeScript

import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import helmet from 'helmet';
import { AppModule } from './app.module';
import { join } from 'path';
import * as express from 'express';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
logger: ['error', 'warn', 'log'],
});
// Serve uploaded files before helmet so they're not blocked
app.use('/uploads', express.static(join(__dirname, '..', 'uploads')));
// Security headers
app.use(
helmet({
contentSecurityPolicy: false, // Handled by Next.js
crossOriginEmbedderPolicy: false,
}),
);
// CORS
const allowedOrigins = (process.env.CORS_ORIGIN || 'http://localhost:3000,http://localhost:3002').split(',');
app.enableCors({
origin: allowedOrigins,
credentials: true,
methods: ['GET', 'POST', 'PATCH', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
});
app.setGlobalPrefix('api');
// Validation with sanitization
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
transformOptions: { enableImplicitConversion: true },
}),
);
const port = process.env.API_PORT || 3001;
await app.listen(port, '0.0.0.0');
console.log(`API running on http://localhost:${port}/api`);
}
bootstrap();