-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (33 loc) · 1.32 KB
/
index.js
File metadata and controls
41 lines (33 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const ivrRoutes = require("./routes/ivrRoutes");
const acsRoutes = require("./routes/acsRoutes");
const bapRoutes = require("./routes/bapRoutes");
const conversationRoutes = require("./routes/conversationRoutes");
const app = express();
// Enable CORS for frontend
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
next();
});
app.use(bodyParser.json());
// Serve static files from frontend directory
app.use(express.static(path.join(__dirname, 'frontend')));
// API Routes
app.use("/ivr", ivrRoutes);
app.use("/acs", acsRoutes);
app.use("/bap", bapRoutes);
app.use("/conversation", conversationRoutes);
// Serve frontend on root path
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'frontend', 'index.html'));
});
const PORT = 3000;
app.listen(PORT, () => {
console.log(`🚀 Middleware running at http://localhost:${PORT}`);
console.log(`🎨 Frontend available at http://localhost:${PORT}/`);
console.log(`📡 API endpoints available at http://localhost:${PORT}/ivr/request`);
});