-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (25 loc) · 743 Bytes
/
index.js
File metadata and controls
31 lines (25 loc) · 743 Bytes
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
const express = require("express");
const cors = require("cors");
// In-memory store for events
const events = [];
// Initialize the app
const app = express();
// Middleware
app.use(cors()); // Enable CORS
app.use(express.json()); // Parse JSON body
// Routes
// Endpoint to receive callbacks
app.post("/api/callbacks/receive", (req, res) => {
const callbackData = req.body;
events.push(callbackData);
res.status(200).json({ message: "Event received successfully" });
});
// Endpoint to view stored events
app.get("/api/callbacks/events", (req, res) => {
res.status(200).json(events);
});
// Start the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});