Files
backend/src/main.ts
2024-03-10 12:49:51 +03:00

40 lines
884 B
TypeScript

import { NestFactory } from '@nestjs/core';
import { AuthModule } from './app.module';
import rateLimit from 'express-rate-limit';
import helmet from 'helmet';
import { setupSwaggerAuthentication } from '../libs/common/src/util/user-auth.swagger.utils';
import { ValidationPipe } from '@nestjs/common';
async function bootstrap() {
const app = await NestFactory.create(AuthModule);
// Enable 'trust proxy' setting
app.use((req, res, next) => {
app.getHttpAdapter().getInstance().set('trust proxy', 1);
next();
});
app.enableCors();
app.use(
rateLimit({
windowMs: 5 * 60 * 1000,
max: 500,
}),
);
app.use(
helmet({
contentSecurityPolicy: false,
}),
);
setupSwaggerAuthentication(app);
app.useGlobalPipes(new ValidationPipe());
await app.listen(4001);
}
console.log('Starting auth at port 4001...');
bootstrap();