Actualizar server.js

This commit is contained in:
2026-02-13 18:15:17 +00:00
parent 3d7e5d8e9c
commit 7f8a469cef

View File

@@ -21,7 +21,7 @@ const {
// --- DIAGNÓSTICO DE INICIO ---
console.log("------------------------------------------------");
console.log("🚀 VERSIÓN NUEVA CARGADA - CON MAPEADOR REAL"); // <--- AHORA SÍ
console.log("🚀 VERSIÓN NUEVA CARGADA - CON MAPEADOR REAL");
console.log("------------------------------------------------");
if (!DATABASE_URL) console.error("❌ FALTA: DATABASE_URL");
if (!JWT_SECRET) console.error("❌ FALTA: JWT_SECRET");
@@ -486,6 +486,19 @@ app.get("/discovery/keys/:provider", authMiddleware, async (req, res) => {
}
});
// RUTA NUEVA: Entrega todos los mapeos guardados por el usuario
app.get("/discovery/mappings", authMiddleware, async (req, res) => {
try {
const q = await pool.query(
"SELECT provider, original_key, target_key FROM variable_mappings WHERE owner_id = $1",
[req.user.accountId]
);
res.json(q.rows);
} catch (e) {
res.status(500).json({ ok: false, error: e.message });
}
});
app.post("/discovery/save", authMiddleware, async (req, res) => {
const client = await pool.connect();
try {