feat: bot WhatsApp Business API — Palmas360 inicial
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
require('dotenv').config();
|
||||
const express = require('express');
|
||||
|
||||
const app = express();
|
||||
|
||||
// Parsear JSON raw para poder verificar firma HMAC de Meta
|
||||
app.use(
|
||||
express.json({
|
||||
verify: (req, _res, buf) => {
|
||||
req.rawBody = buf;
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
// ─── Rutas ───────────────────────────────────────────────────────────────────
|
||||
const wpWebhook = require('./admin/v1/wp-webhook');
|
||||
app.use('/admin/v1/wp-webhook', wpWebhook);
|
||||
|
||||
// Health check
|
||||
app.get('/health', (_req, res) => res.json({ status: 'ok', service: 'bot-palmas360' }));
|
||||
|
||||
// 404
|
||||
app.use((_req, res) => res.status(404).json({ error: 'Ruta no encontrada' }));
|
||||
|
||||
// ─── Inicio ───────────────────────────────────────────────────────────────────
|
||||
const PORT = process.env.PORT || 3000;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`✅ Servidor corriendo en puerto ${PORT}`);
|
||||
console.log(`📡 Webhook WhatsApp → /admin/v1/wp-webhook`);
|
||||
});
|
||||
Reference in New Issue
Block a user