Fix Build Error
Deploy / deploy (push) Successful in 47s

This commit is contained in:
Rayyan Syahbani Hermanto
2026-09-07 23:44:40 +07:00
parent 06f4fd06ff
commit 8a278281ce
38 changed files with 927 additions and 427 deletions
+32 -4
View File
@@ -1,6 +1,10 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const common_1 = require("@nestjs/common");
const cookie_parser_1 = __importDefault(require("cookie-parser"));
const core_1 = require("@nestjs/core");
const config_1 = require("@nestjs/config");
const swagger_1 = require("@nestjs/swagger");
@@ -8,13 +12,35 @@ const app_module_1 = require("./app.module");
async function bootstrap() {
const app = await core_1.NestFactory.create(app_module_1.AppModule);
const config = app.get(config_1.ConfigService);
app.setGlobalPrefix('api');
const logger = new common_1.Logger('Bootstrap');
// enable cookie parser so req.cookies is populated
app.use((0, cookie_parser_1.default)());
app.setGlobalPrefix('');
app.useGlobalPipes(new common_1.ValidationPipe({
whitelist: true,
transform: true,
forbidNonWhitelisted: true,
}));
app.enableCors();
// CORS configuration: only allow configured frontend origins and enable credentials
const allowedOrigins = [];
const frontend = config.get('FRONTEND_URL');
const prodFrontend = config.get('PRODUCTION_FRONTEND_URL');
if (frontend)
allowedOrigins.push(frontend);
if (prodFrontend)
allowedOrigins.push(prodFrontend);
app.enableCors({
origin: allowedOrigins,
credentials: true,
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
allowedHeaders: [
'Content-Type',
'Authorization',
'Accept',
'Origin',
'X-Requested-With',
],
});
const swaggerEnabled = config.get('SWAGGER_ENABLED') === 'true';
if (swaggerEnabled) {
const swaggerConfig = new swagger_1.DocumentBuilder()
@@ -24,11 +50,13 @@ async function bootstrap() {
.addBearerAuth()
.build();
const document = swagger_1.SwaggerModule.createDocument(app, swaggerConfig);
swagger_1.SwaggerModule.setup('docs', app, document);
swagger_1.SwaggerModule.setup('ApiList', app, document);
}
const port = config.get('PORT') || 3000;
logger.log(`Allowed CORS origins: ${JSON.stringify(allowedOrigins)}`);
logger.log(`Server listening on port ${port}`);
await app.listen(port);
console.log(`Server running on http://localhost:${port}`);
logger.log(`Server running on http://localhost:${port}`);
}
bootstrap();
//# sourceMappingURL=main.js.map