project init

This commit is contained in:
2026-02-06 02:17:59 +03:00
commit b9d9b9ed17
129 changed files with 22835 additions and 0 deletions

60
apps/api/src/main.ts Normal file
View File

@ -0,0 +1,60 @@
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import helmet from 'helmet';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const configService = app.get(ConfigService);
// Security
app.use(helmet());
// CORS (веб на порту 3125)
const allowedOrigins = [
configService.get('NEXT_PUBLIC_APP_URL'),
'http://localhost:3125',
'http://localhost:3000',
].filter(Boolean) as string[];
app.enableCors({
origin: allowedOrigins.length ? allowedOrigins : 'http://localhost:3125',
credentials: true,
});
// Global prefix
app.setGlobalPrefix('api');
// Validation
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
transformOptions: {
enableImplicitConversion: true,
},
})
);
// Swagger
if (configService.get('NODE_ENV') !== 'production') {
const config = new DocumentBuilder()
.setTitle('CourseCraft API')
.setDescription('AI-powered course creation platform API')
.setVersion('1.0')
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('docs', app, document);
}
const port = configService.get('PORT') || 3001;
await app.listen(port);
console.log(`🚀 API is running on: http://localhost:${port}/api`);
console.log(`📚 Swagger docs: http://localhost:${port}/docs`);
}
bootstrap();