@@ -0,0 +1,24 @@
|
||||
import http from "node:http";
|
||||
|
||||
const port = Number(process.env.PORT ?? "9999");
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
if (req.method === "POST") {
|
||||
let body = "";
|
||||
req.on("data", (c) => {
|
||||
body += c;
|
||||
});
|
||||
req.on("end", () => {
|
||||
console.log(`[${new Date().toISOString()}] webhook ${body}`);
|
||||
res.writeHead(200, { "Content-Type": "text/plain" });
|
||||
res.end("ok");
|
||||
});
|
||||
return;
|
||||
}
|
||||
res.writeHead(200, { "Content-Type": "text/plain" });
|
||||
res.end("POST JSON payloads from TLM bot webhooks here.");
|
||||
});
|
||||
|
||||
server.listen(port, () => {
|
||||
console.log(`Sample bot webhook receiver listening on http://127.0.0.1:${port}`);
|
||||
});
|
||||
Reference in New Issue
Block a user