streamflix-api / src /main.ts
Akshar2325
✨ feat(upload): support large video processing from wasabi
61d4c9c
Raw
History Blame
1.41 kB
import {
ValidationPipe,
VersioningType,
VERSION_NEUTRAL,
} from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { ConfigService } from '@nestjs/config';
import helmet from 'helmet';
import { AppModule } from './app.module';
import { PrismaService } from './shared/modules/prisma/prisma.service';
import { setupSwagger } from './swagger-setup';
import * as bodyParser from 'body-parser';
async function bootstrap() {
const app = await NestFactory.create(AppModule, { cors: true });
const configService = app.get(ConfigService);
const prismaService = app.get(PrismaService);
await prismaService.enableShutdownHooks(app);
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
app.enableVersioning({
type: VersioningType.URI,
defaultVersion: VERSION_NEUTRAL,
});
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
transform: true,
}),
);
if (process.env.NODE_ENV === 'production') {
app.use(helmet());
}
setupSwagger(app);
app.enableCors({
origin: configService.get('CORS_ORIGIN') || '*',
credentials: true,
});
const port = process.env.PORT || 3000;
await app.listen(port);
console.log(`πŸš€ Application is running on: http://localhost:${port}`);
console.log(`πŸ“š Swagger documentation: http://localhost:${port}/api`);
}
bootstrap();