Files
planilla/agent/index.js
josedario87 745168cf51
Some checks failed
build-and-push / deploy (push) Has been skipped
build-and-push / build (push) Failing after 6s
sistema creado v0.5.0
2025-05-14 16:10:41 -06:00

36 lines
925 B
JavaScript

/* nucleo-bot ― index.js */
import express from 'express';
import morgan from 'morgan';
import { config } from './config.js';
import { log } from './logger.js';
import { router } from './routes.js';
import {
waitForGateway,
clearWebhooks,
registerWebhook
} from './whatsapp.js';
export let globalMemory = {};
/* 🌐 Express app */
const app = express();
app.use(express.json({ limit: '1mb' }));
app.use(morgan('[:date[iso]] :method :url :status - :response-time ms'));
app.use(router);
/* 🚀 Bootstrap */
async function bootstrap() {
await waitForGateway();
await clearWebhooks();
await registerWebhook();
}
/* 🏁 Arranque */
app.listen(config.PORT, () => {
log('info', `🪪 Versión del bot: ${config.VERSION}`);
log('info', `🚀 nucleo-bot escuchando en :${config.PORT}`);
bootstrap().catch(e => log('error', 'Error en bootstrap:', e.message));
});