Api endpoint added /api/latency-targets
All checks were successful
Docker / build-and-push (push) Successful in 1m48s
All checks were successful
Docker / build-and-push (push) Successful in 1m48s
This commit is contained in:
20
README.md
20
README.md
@@ -92,6 +92,26 @@ GET /api/status
|
||||
|
||||
`status` is `"up"` for any response (including 4xx — the server is reachable), `"down"` for connection errors and 5xx, `"unknown"` before the first check completes.
|
||||
|
||||
```
|
||||
GET /api/latency-targets
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"refreshedAt": "2026-07-26T18:00:00Z",
|
||||
"targets": [
|
||||
{
|
||||
"key": "wisp.dev.example.com",
|
||||
"name": "Wisp",
|
||||
"url": "https://wisp.dev.example.com/",
|
||||
"source": "npm"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
`/api/latency-targets` exposes the current computed check list after include-pattern filtering plus admin overrides/manual targets, making it suitable as a source of truth for downstream probe consumers.
|
||||
|
||||
### Admin API
|
||||
|
||||
All routes below `/api/admin` (except `/auth/check`) require an `X-Admin-Password` header matching `ADMIN_PASSWORD`. Returns `503` for every route if `ADMIN_PASSWORD` is unset.
|
||||
|
||||
@@ -60,7 +60,7 @@ async function refreshNpmHosts(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
function currentTargets(): CheckTarget[] {
|
||||
export function currentTargets(): CheckTarget[] {
|
||||
return computeTargets(rawHosts, getAllOverrides(), listManualTargets());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { config } from './config.js';
|
||||
import { startChecker, getStore } from './checker.js';
|
||||
import { startChecker, getStore, currentTargets } from './checker.js';
|
||||
import { renderPage } from './page.js';
|
||||
import { renderAdminPage } from './adminPage.js';
|
||||
import { router as adminRouter } from './admin.js';
|
||||
@@ -13,6 +13,13 @@ app.get('/api/status', (_req, res) => {
|
||||
res.json(getStore());
|
||||
});
|
||||
|
||||
app.get('/api/latency-targets', (_req, res) => {
|
||||
res.json({
|
||||
refreshedAt: new Date().toISOString(),
|
||||
targets: currentTargets(),
|
||||
});
|
||||
});
|
||||
|
||||
app.use('/api/admin', adminRouter);
|
||||
|
||||
app.get('/admin', (_req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user