Files
tehran_taj/apps/api/src/main.ts
T

29 lines
1.1 KiB
TypeScript
Raw Normal View History

2026-09-09 06:46:27 +03:30
import 'reflect-metadata';
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'node:path';
2026-09-09 06:46:27 +03:30
import { AppModule } from './app.module';
import { prepareDatabase } from './prisma/bootstrap';
2026-09-09 06:46:27 +03:30
import { PrismaExceptionFilter } from './prisma/prisma-exception.filter';
async function bootstrap() {
await prepareDatabase();
const app = await NestFactory.create<NestExpressApplication>(AppModule);
2026-09-09 06:46:27 +03:30
app.setGlobalPrefix('api');
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
app.useGlobalFilters(new PrismaExceptionFilter());
app.enableCors();
// Uploaded files, mounted OUTSIDE the /api prefix so the URLs stored on
// UploadedFile.url ("/uploads/<name>") resolve directly.
app.useStaticAssets(process.env.UPLOAD_DIR ?? join(process.cwd(), 'storage', 'uploads'), {
prefix: '/uploads/',
index: false,
dotfiles: 'deny',
});
// Bind all interfaces explicitly so the container is reachable from nginx.
await app.listen(process.env.PORT ?? 3000, '0.0.0.0');
2026-09-09 06:46:27 +03:30
}
bootstrap();