UNPKG

skailan-conversations

Version:

Servicio de conversaciones y mensajería para Skailan

45 lines 1.64 kB
import express from "express"; import { handleTelegramWebhook } from "./telegram-webhook"; const app = express(); const PORT = process.env.PORT || 3007; app.use(express.json()); // Middleware para logging app.use((req, res, next) => { console.log(`${new Date().toISOString()} - ${req.method} ${req.path}`); next(); }); // Endpoint principal app.get("/", (req, res) => { res.send("Conversations Service API is running!"); }); // Endpoint para recibir webhooks de Telegram app.post("/webhook/telegram", handleTelegramWebhook); // Endpoint para verificar que el webhook está funcionando app.get("/webhook/telegram", (req, res) => { res.json({ message: "Telegram webhook endpoint está activo", timestamp: new Date().toISOString(), status: "ok", }); }); // Endpoint de prueba app.get("/test", (req, res) => { res.json({ message: "Servidor funcionando correctamente", timestamp: new Date().toISOString(), endpoints: { webhook: "/webhook/telegram", test: "/test", }, }); }); app.listen(PORT, () => { console.log(`🚀 Servidor de Conversations iniciado en puerto ${PORT}`); console.log(`📱 Endpoint webhook: http://localhost:${PORT}/webhook/telegram`); console.log(`🧪 Endpoint de prueba: http://localhost:${PORT}/test`); console.log("\n💡 Instrucciones:"); console.log(" 1. Configura el webhook de Telegram para apuntar a este servidor"); console.log(" 2. Envía un mensaje al bot @iapunto_bot"); console.log(" 3. Verifica que aparezca en la consola"); }); //# sourceMappingURL=simple-server.js.map