separado en routes

This commit is contained in:
Lucas Tettamanti
2026-01-14 13:03:11 -03:00
parent 2d01972619
commit 47ba68049f
4 changed files with 108 additions and 69 deletions

32
src/app.js Normal file
View File

@@ -0,0 +1,32 @@
import express from "express";
import cors from "cors";
import path from "path";
import { fileURLToPath } from "url";
import { createSimulatorRouter } from "./routes/simulator.js";
import { createEvolutionRouter } from "./routes/evolution.js";
export function createApp({ tenantId }) {
const app = express();
app.use(cors());
app.use(express.json({ limit: "1mb" }));
// Serve /public as static (UI + webcomponents)
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const publicDir = path.join(__dirname, "..", "public");
app.use(express.static(publicDir));
// --- Integraciones / UI ---
app.use(createSimulatorRouter({ tenantId }));
app.use(createEvolutionRouter());
// Home (UI)
app.get("/", (req, res) => {
res.sendFile(path.join(publicDir, "index.html"));
});
return app;
}