mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 07:07:21 +00:00
40 lines
884 B
TypeScript
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();
|