2025-10-21 10:42:59 +00:00
|
|
|
import { NestFactory } from '@nestjs/core';
|
|
|
|
|
import { AppModule } from './app.module';
|
|
|
|
|
import cookieParser from 'cookie-parser';
|
|
|
|
|
import { ConfigService } from '@nestjs/config';
|
2025-10-27 06:41:51 +00:00
|
|
|
import { ValidationPipe } from '@nestjs/common';
|
|
|
|
|
|
|
|
|
|
(BigInt.prototype as any).toJSON = function () {
|
|
|
|
|
return this.toString();
|
|
|
|
|
};
|
2025-10-21 10:42:59 +00:00
|
|
|
|
|
|
|
|
async function bootstrap() {
|
|
|
|
|
const app = await NestFactory.create(AppModule);
|
|
|
|
|
const configService = app.get(ConfigService);
|
2025-10-27 06:41:51 +00:00
|
|
|
app.setGlobalPrefix('api/');
|
2025-10-30 05:15:06 +00:00
|
|
|
app.enableCors({
|
|
|
|
|
origin: 'http://localhost:5173',
|
|
|
|
|
credentials: true,
|
|
|
|
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
|
|
|
|
|
allowedHeaders: 'Content-Type, Accept, X-CSRF-Token',
|
|
|
|
|
});
|
2025-10-27 06:41:51 +00:00
|
|
|
app.useGlobalPipes(
|
|
|
|
|
new ValidationPipe({
|
|
|
|
|
transform: true,
|
|
|
|
|
whitelist: true,
|
|
|
|
|
forbidNonWhitelisted: true,
|
|
|
|
|
}),
|
|
|
|
|
);
|
2025-10-21 10:42:59 +00:00
|
|
|
app.use(cookieParser(configService.get<string>('COOKIE_SECRET')));
|
|
|
|
|
await app.listen(configService.get<number>('PORT') ?? 1323);
|
|
|
|
|
}
|
|
|
|
|
bootstrap();
|
2025-10-30 05:15:06 +00:00
|
|
|
|
|
|
|
|
// Rate limiting
|