Spaces:
Runtime error
Runtime error
File size: 1,837 Bytes
97dab2a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import { NestFactory } from '@nestjs/core';
import { ApigatewayModule } from './apigateway.module';
import { ApploggerService } from '@bpm/common';
async function bootstrap() {
const context = 'apigateway';
const logger = new ApploggerService(context);
logger.log('π οΈ Starting up the NestJS Application...\n', context);
logger.log('π¦ Loading modules...\n', context);
const app = await NestFactory.create(ApigatewayModule);
app.enableShutdownHooks(); // π Add this
app.enableCors({
origin: [/http:\/\/localhost:\d+$/, 'https://srepoc-northwind-vuejs-ctbmh6bufhgufqea.b01.azurefd.net'], // Allow all requests from localhost on any port
credentials: true, // Enable credentials if needed (cookies, auth headers, etc.)
});
app.setGlobalPrefix('api'); // π This sets /api as the prefix
const port = process.env.PORT || 3001;
try {
await app.listen(port, () => {
logger.log('β
App Modules initialized successfully\n', context);
logger.log('π Enabling global configurations...\n', context);
logger.log(
`π Application is running at: http://localhost:${port}\n`,
context,
);
logger.log('π‘ Ready to accept incoming requests!\n', context);
logger.log('π§ Powered by NestJS β€οΈ\n', context);
});
} catch (err) {
logger.error('β Failed to start application\n', err.stack);
if (app) {
await app.close();
}
}
// OS signal listeners (optional)
process.on('SIGINT', async () => {
logger.warn('π SIGINT received. Gracefully shutting down...', context);
await app.close();
process.exit(1);
});
process.on('SIGTERM', async () => {
logger.warn('π SIGTERM received. Gracefully shutting down...', context);
await app.close();
process.exit(1);
});
}
bootstrap();
|