Spaces:
Build error
Build error
import * as express from "express"; | |
const app = express(); | |
// parse HTTP request bodies as json | |
app.use(express.json()); | |
app.get("/", (req, res) => { | |
res.json({ hello: "world" }); | |
}); | |
app.post("/", (req, res) => { | |
if (req.header("X-Webhook-Secret") !== process.env.WEBHOOK_SECRET) { | |
return res.status(400).json({ error: "incorrect secret" }); | |
} | |
console.log(req.body); | |
res.json({ success: true }); | |
}); | |
const PORT = 7860; | |
app.listen(PORT, () => { | |
console.debug(`server started at http://localhost:${PORT}`); | |
}); | |