mirror of
https://github.com/koichixD/uptime-kuma.git
synced 2026-09-04 09:13:21 +00:00
feat: Domain name expiry (#6413)
Co-authored-by: AiroPi <47398145+AiroPi@users.noreply.github.com> Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
co-authored by
AiroPi
Frank Elsinga
parent
f3c76dbc6f
commit
eb0b6cdb09
@@ -0,0 +1,28 @@
|
||||
const express = require("express");
|
||||
const bodyParser = require("body-parser");
|
||||
|
||||
/**
|
||||
* @param {number} port Port number
|
||||
* @param {string} url Webhook URL
|
||||
* @param {number} timeout Timeout
|
||||
* @returns {Promise<object>} Webhook data
|
||||
*/
|
||||
async function mockWebhook(port, url, timeout = 2500) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const app = express();
|
||||
const tmo = setTimeout(() => {
|
||||
server.close();
|
||||
reject({ reason: "Timeout" });
|
||||
}, timeout);
|
||||
app.use(bodyParser.json()); // Middleware to parse JSON bodies
|
||||
app.post(`/${url}`, (req, res) => {
|
||||
res.status(200).send("OK");
|
||||
server.close();
|
||||
tmo && clearTimeout(tmo);
|
||||
resolve(req.body);
|
||||
});
|
||||
const server = app.listen(port);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = mockWebhook;
|
||||
Reference in New Issue
Block a user