Files
FWS-DiscordBot/src/web/api/status.js
T
nocodeandClaude Opus 5 a1e1de7734 feat(web): publish a public status page at /status
Checking whether the service is up required an account, so the answer
lived where the people asking could not reach it.

The page is rendered on the server with no script at all and refreshes
through a meta tag: a status page that needs a working browser is
useless at the moment it is read. Two rules follow from it being public.
A repository the forge does not list as public keeps its environment
visible but loses its name, and the banner always states the worst true
thing — a failed deployment forbids the green headline even while the
bot answers. WEB_PUBLIC_STATUS=false removes page and route together.

/api/status gives the same in JSON, which is what a monitor should watch
rather than /api/health — the latter only says the process is alive.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-24 18:46:26 +02:00

22 lines
696 B
JavaScript

import { env } from '../../config/env.js';
import { notFound } from '../http.js';
import { statusSnapshot } from '../services/status-service.js';
/**
* Machine-readable twin of the public status page (M19).
*
* `/api/health` says whether the process is alive, which is what a load
* balancer asks. This says what state the service is in, which is what a person
* — or an uptime monitor with a dashboard — asks.
*/
export function registerStatusRoutes(router) {
router.get(
'/api/status',
async ({ context }) => {
if (!env.web.publicStatus) throw notFound('La page de statut est désactivée.');
return statusSnapshot(context);
},
{ public: true },
);
}