separado en routes
This commit is contained in:
32
src/app.js
Normal file
32
src/app.js
Normal 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user