import { Router } from "express"; import { NOT_FOUND, resolveShareLink } from "../services/shareLinks.js"; import { buildPublicStatus } from "../services/statusPage.js"; import { rateLimit } from "../utils/rateLimit.js"; import { asyncHandler } from "../utils/asyncHandler.js"; export const publicStatusRouter = Router(); // No sign-in: the secret in the address is the whole of the access, so this reads nothing but the page's own picture, and answers a link that // doesn't work — never made, ended, taken back, or a wall's rather than a status page's — in the same words. const limiter = rateLimit({ windowMs: 60_000, max: 60, message: "Too many requests. Wait a minute." }); publicStatusRouter.get("/:token", limiter, asyncHandler(async (req, res) => { const link = await resolveShareLink(req.params.token); if (!link || link.kind !== "status") return res.status(404).json(NOT_FOUND); res.setHeader("Cache-Control", "no-store"); res.setHeader("X-Robots-Tag", "noindex, nofollow"); res.json(await buildPublicStatus(link)); }));