|
| 1 | +// This is an insecure mock server for testing purposes |
| 2 | + |
| 3 | +import express from "express"; |
| 4 | +import { getConfig } from "./src/handlers/getConfig.ts"; |
| 5 | +import { captureEvent } from "./src/handlers/captureEvent.ts"; |
| 6 | +import { listEvents } from "./src/handlers/listEvents.ts"; |
| 7 | +import { createApp } from "./src/handlers/createApp.ts"; |
| 8 | +import { checkToken } from "./src/middleware/checkToken.ts"; |
| 9 | +import { updateConfig } from "./src/handlers/updateConfig.ts"; |
| 10 | +import { lists } from "./src/handlers/lists.ts"; |
| 11 | +import { updateIPLists } from "./src/handlers/updateLists.ts"; |
| 12 | +import { realtimeConfig } from "./src/handlers/realtimeConfig.ts"; |
| 13 | + |
| 14 | +const app = express(); |
| 15 | +app.set("trust proxy", false); |
| 16 | +app.set("x-powered-by", false); |
| 17 | + |
| 18 | +const port = process.env.PORT || 3000; |
| 19 | + |
| 20 | +app.use(express.json()); |
| 21 | + |
| 22 | +app.get("/api/runtime/config", checkToken, getConfig); |
| 23 | +app.post("/api/runtime/config", checkToken, updateConfig); |
| 24 | + |
| 25 | +// Realtime polling endpoint |
| 26 | +app.get("/config", checkToken, realtimeConfig); |
| 27 | + |
| 28 | +app.get("/api/runtime/events", checkToken, listEvents); |
| 29 | +app.post("/api/runtime/events", checkToken, captureEvent); |
| 30 | + |
| 31 | +app.get("/api/runtime/firewall/lists", checkToken, lists); |
| 32 | +app.post("/api/runtime/firewall/lists", checkToken, updateIPLists); |
| 33 | + |
| 34 | +app.post("/api/runtime/apps", createApp); |
| 35 | + |
| 36 | +app.listen(port, () => { |
| 37 | + console.log(`Server is running on port ${port}`); |
| 38 | +}); |
0 commit comments