mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-25 15:55:40 -04:00
[status page]
This commit is contained in:
parent
34abff4724
commit
f9311e4e7f
4 changed files with 63 additions and 47 deletions
|
@ -157,53 +157,9 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
|
|||
response.redirect("https://github.com/louislam/uptime-kuma/wiki/Reset-Password-via-CLI");
|
||||
});
|
||||
|
||||
// ***************************
|
||||
// Public API
|
||||
// ***************************
|
||||
|
||||
// Status Page Config
|
||||
app.get("/api/status-page/config", async (_request, response) => {
|
||||
allowDevAllOrigin(response);
|
||||
let config = getSettings("statusPage");
|
||||
|
||||
if (! config.statusPageTheme) {
|
||||
config.statusPageTheme = "light";
|
||||
}
|
||||
|
||||
response.json(config);
|
||||
});
|
||||
|
||||
// Status Page - Monitor List
|
||||
app.get("/api/status-page/monitor-list", async (_request, response) => {
|
||||
allowDevAllOrigin(response);
|
||||
|
||||
const monitorList = {};
|
||||
let list = await R.find("monitor", " public = 1 ORDER BY weight DESC, name ", [
|
||||
]);
|
||||
|
||||
for (let monitor of list) {
|
||||
monitorList[monitor.id] = await monitor.toJSON();
|
||||
}
|
||||
|
||||
response.json(monitorList);
|
||||
});
|
||||
|
||||
// Status Page Polling Data
|
||||
app.get("/api/status-page/heartbeat", async (_request, response) => {
|
||||
allowDevAllOrigin(response);
|
||||
|
||||
const monitorList = {};
|
||||
let list = await R.find("", " ", [
|
||||
])
|
||||
|
||||
for (let monitor of list) {
|
||||
monitorList[monitor.id] = await monitor.toJSON();
|
||||
}
|
||||
|
||||
response.json({
|
||||
monitorList: monitorList,
|
||||
});
|
||||
});
|
||||
// API Router
|
||||
const apiRouter = require("./routers/api-router");
|
||||
app.use(apiRouter);
|
||||
|
||||
// Universal Route Handler, must be at the end of all express route.
|
||||
app.get("*", async (_request, response) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue