Add status pages (a share link kind) and a downloadable Grafana dashboard
- Share links can open a status page: an admin picks servers, integrations and Uptime Kuma monitors and names them; the public sees only those names, Working / Not working / Being worked on / Can't tell, an optional message and the 30-day figure (share_links.kind/ title/message and status_items, migration 0033). A status address doesn't open the wall and the other way round; Uptime Kuma is asked at most every 30 seconds - Grafana dashboard built from code (download in Settings -> API and webhooks); a test checks it only uses series /metrics serves - Tests and docs Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2744a84719
commit
5cc51c57de
24 files changed
+4880
-35
No files matched your search
@@ -5,7 +5,7 @@
|
||||
import { createHash, randomBytes } from "node:crypto";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "../db/client.js";
|
||||
import { shareLinks, type ShareLinkDetail } from "../db/schema.js";
|
||||
import { shareLinks, type ShareLinkDetail, type ShareLinkKind } from "../db/schema.js";
|
||||
|
||||
export type ShareLinkRow = typeof shareLinks.$inferSelect;
|
||||
|
||||
@@ -17,7 +17,7 @@ const hash = (token: string) => createHash("sha256").update(token).digest("hex")
|
||||
/** A link isn't recorded as used more than once in this time, so a screen refreshing every few seconds doesn't write the database each time. */
|
||||
const USED_WRITE_GAP_MS = 60_000;
|
||||
|
||||
export async function createShareLink(params: { label: string; detail: ShareLinkDetail; expiresInDays: number | null; createdBy: string; now?: Date }): Promise<{ link: ShareLinkRow; token: string }> {
|
||||
export async function createShareLink(params: { label: string; detail: ShareLinkDetail; kind?: ShareLinkKind; title?: string | null; message?: string | null; expiresInDays: number | null; createdBy: string; now?: Date }): Promise<{ link: ShareLinkRow; token: string }> {
|
||||
const now = params.now ?? new Date();
|
||||
const token = randomBytes(24).toString("base64url");
|
||||
const [link] = await db
|
||||
@@ -27,6 +27,9 @@ export async function createShareLink(params: { label: string; detail: ShareLink
|
||||
tokenHash: hash(token),
|
||||
tokenPrefix: token.slice(0, 6),
|
||||
detail: params.detail,
|
||||
kind: params.kind ?? "wall",
|
||||
title: params.title?.trim() || null,
|
||||
message: params.message?.trim() || null,
|
||||
createdBy: params.createdBy,
|
||||
expiresAt: params.expiresInDays === null ? null : new Date(now.getTime() + params.expiresInDays * 86_400_000).toISOString(),
|
||||
})
|
||||
@@ -53,6 +56,9 @@ export function publicShareLink(link: ShareLinkRow, now: Date = new Date()) {
|
||||
label: link.label,
|
||||
tokenPrefix: link.tokenPrefix,
|
||||
detail: link.detail,
|
||||
kind: link.kind,
|
||||
title: link.title,
|
||||
message: link.message,
|
||||
createdBy: link.createdBy,
|
||||
createdAt: link.createdAt,
|
||||
expiresAt: link.expiresAt,
|
||||
|
||||
Reference in new issue
Block a user