|
|
|
@ -2,7 +2,7 @@ let express = require("express");
|
|
|
|
|
const apicache = require("../modules/apicache");
|
|
|
|
|
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
|
|
|
|
const StatusPage = require("../model/status_page");
|
|
|
|
|
const { allowDevAllOrigin, send403 } = require("../util-server");
|
|
|
|
|
const { allowAllOrigin, allowDevAllOrigin, send403 } = require("../util-server");
|
|
|
|
|
const { R } = require("redbean-node");
|
|
|
|
|
const Monitor = require("../model/monitor");
|
|
|
|
|
|
|
|
|
@ -26,6 +26,39 @@ router.get("/status-page", cache("5 minutes"), async (request, response) => {
|
|
|
|
|
await StatusPage.handleStatusPageResponse(response, server.indexHTML, slug);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Status page config, incident, monitor list with status ("up" or "down")
|
|
|
|
|
router.get("/api/status-page/:slug/summary", cache("5 minutes"), async (request, response) => {
|
|
|
|
|
allowAllOrigin(response);
|
|
|
|
|
let slug = request.params.slug;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Get Status Page
|
|
|
|
|
let statusPage = await R.findOne("status_page", " slug = ? ", [
|
|
|
|
|
slug
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
if (!statusPage) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let statusPageData = await StatusPage.getStatusPageData(statusPage, true);
|
|
|
|
|
|
|
|
|
|
if (!statusPageData) {
|
|
|
|
|
response.statusCode = 404;
|
|
|
|
|
response.json({
|
|
|
|
|
msg: "Not Found"
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Response
|
|
|
|
|
response.json(statusPageData);
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
send403(response, error.message);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Status page config, incident, monitor list
|
|
|
|
|
router.get("/api/status-page/:slug", cache("5 minutes"), async (request, response) => {
|
|
|
|
|
allowDevAllOrigin(response);
|
|
|
|
|