43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { ValidationPipe } from '@nestjs/common';
|
|
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
import * as cookieParser from 'cookie-parser';
|
|
import { AppModule } from './app.module';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
|
|
app.use(cookieParser());
|
|
|
|
app.enableCors({
|
|
origin: process.env.FRONTEND_URL ?? 'http://localhost:3000',
|
|
credentials: true,
|
|
});
|
|
|
|
app.setGlobalPrefix('api/v1');
|
|
|
|
app.useGlobalPipes(
|
|
new ValidationPipe({
|
|
whitelist: true,
|
|
transform: true,
|
|
transformOptions: { enableImplicitConversion: true },
|
|
}),
|
|
);
|
|
|
|
const swaggerConfig = new DocumentBuilder()
|
|
.setTitle('StudioFlow API')
|
|
.setDescription('YouTube Upload Manager — REST API')
|
|
.setVersion('1.0')
|
|
.addBearerAuth()
|
|
.build();
|
|
|
|
const document = SwaggerModule.createDocument(app, swaggerConfig);
|
|
SwaggerModule.setup('api/docs', app, document);
|
|
|
|
const port = process.env.PORT ?? 3001;
|
|
await app.listen(port);
|
|
console.log(`StudioFlow API running on :${port}`);
|
|
}
|
|
|
|
bootstrap();
|