Fix 1 - Migrar Codigo a TS #2

Merged
giacchetta merged 4 commits from 1-migrar-js-a-ts into main 2025-07-03 17:52:58 -03:00
3 changed files with 26 additions and 3 deletions
Showing only changes of commit ee371b82d0 - Show all commits

6
Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM docker.io/library/node:22-alpine
LABEL org.opencontainers.image.source https://gianet.us/codyops/nucleus
COPY . /opt
WORKDIR /opt
RUN npm run build
CMD npm run start

View File

@ -4,7 +4,7 @@
"description": "CodyOps Nucleus",
"main": "dist/index.js",
"scripts": {
"build": "npx tsc",
"build": "npm i && npx tsc",
"start": "node dist/main.js",
"dev": "tsc-watch --noClear --onSuccess 'node ./dist/main.js'"
},

View File

@ -35,6 +35,23 @@ app.post(`/${processor}`, jsonParser, async (req: Request, res: Response) => {
res.sendStatus(201);
})
app.listen(port, () => {
const server = app.listen(port, () => {
console.log('Serving function...');
});
});
function shutdown(signal: string) {
console.log(`Received ${signal}. Shutting down gracefully...`);
server.close(() => {
console.log('HTTP server closed.');
process.exit(0);
});
setTimeout(() => {
console.error('Forced shutdown due to timeout.');
process.exit(1);
}, 10000);
}
process.on('SIGTERM', () => shutdown('SIGTERM'));
process.on('SIGINT', () => shutdown('SIGINT')); // Handles Ctrl+C