This repository has been archived on 2026-04-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Inventory_backend/dist/main.js
2025-09-17 08:50:07 +02:00

35 lines
1.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@nestjs/core");
const common_1 = require("@nestjs/common");
const app_module_1 = require("./app.module");
async function bootstrap() {
const app = await core_1.NestFactory.create(app_module_1.AppModule);
const allowedOrigins = process.env.CORS_ORIGIN
? process.env.CORS_ORIGIN.split(',').map(origin => origin.trim())
: ['http://localhost:3001'];
app.enableCors({
origin: (origin, callback) => {
if (!origin || allowedOrigins.includes(origin)) {
callback(null, true);
}
else {
callback(new Error(`Origin ${origin} not allowed by CORS`));
}
},
credentials: true,
});
app.useGlobalPipes(new common_1.ValidationPipe({
whitelist: process.env.VALIDATION_WHITELIST === 'true',
forbidNonWhitelisted: process.env.VALIDATION_FORBID_NON_WHITELISTED === 'true',
transform: process.env.VALIDATION_TRANSFORM === 'true',
}));
const apiPrefix = process.env.API_PREFIX || 'api';
app.setGlobalPrefix(apiPrefix);
const port = Number(process.env.PORT) || 3000;
await app.listen(port);
console.log(`Application is running on: http://localhost:${port}`);
console.log(`Environment: ${process.env.NODE_ENV || 'development'}`);
}
bootstrap();
//# sourceMappingURL=main.js.map