- Endpoints: HTTP, TCP and TLS checks with answer time, uptime and certificate expiry; failures and expiring certificates become alerts and notifications; linked to a server for maintenance and tags - Restore tests: record when a backup was restored and how it went; failed tests always alert, overdue ones with a limit set; shown on the Backup coverage page - Change log: one filterable timeline made from the audit log and the incident record Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
28 lines
1.4 KiB
TypeScript
28 lines
1.4 KiB
TypeScript
import { Router } from "express";
|
|
import { requireAuth, requireRole } from "../auth/middleware.js";
|
|
import { CHANGE_KINDS, KIND_LABELS, getChangeLog, type ChangeKind } from "../services/changeLog.js";
|
|
import { asyncHandler } from "../utils/asyncHandler.js";
|
|
|
|
export const changesRouter = Router();
|
|
|
|
// Like the audit log it is made from: operators and administrators.
|
|
changesRouter.use(requireAuth, requireRole("operator"));
|
|
|
|
// ?days=7 &kind=settings &serverId=3 &q=word &before=ISO (the next page) &limit=200
|
|
changesRouter.get("/", asyncHandler(async (req, res) => {
|
|
const days = Number(req.query.days);
|
|
const serverId = typeof req.query.serverId === "string" && /^\d+$/.test(req.query.serverId) ? Number(req.query.serverId) : undefined;
|
|
const kind = CHANGE_KINDS.find((k) => k === req.query.kind) as ChangeKind | undefined;
|
|
const before = typeof req.query.before === "string" && !Number.isNaN(Date.parse(req.query.before)) ? req.query.before : undefined;
|
|
const limit = Number(req.query.limit);
|
|
const result = await getChangeLog({
|
|
days: Number.isFinite(days) && days >= 1 ? days : 7,
|
|
kind,
|
|
serverId,
|
|
q: typeof req.query.q === "string" ? req.query.q.slice(0, 100) : undefined,
|
|
before,
|
|
limit: Number.isFinite(limit) && limit >= 1 ? limit : 200,
|
|
});
|
|
res.json({ ...result, kinds: CHANGE_KINDS.map((k) => ({ id: k, label: KIND_LABELS[k] })) });
|
|
}));
|