Admin UI metrics and config workflow polish#84
Closed
nonithebot wants to merge 33 commits into
Closed
Conversation
…match-docs Fix/purge hex minimatch docs Fixes ajaysinghj8#9
…trics feat(metrics): add prometheus-compatible metrics endpoint for cache m…
…mary, purge safety - nameSpaceHandler: match both /path and /path/ against allow/deny glob patterns so trailing-slash requests are handled consistently without pattern-specific quirks - config.reader: warn on unknown namespace keys (with list of known keys) to catch typos before they silently become no-ops - index.ts: print a human-readable startup summary of config version, enabled features, and each namespace (expose→target, cache config, allow/deny lists) - purgeCache: add broadPatternWarning() — purge responses include a 'warning' field when the pattern lacks the 'O:<namespace>' prefix that scopes it to one namespace; add optional OSHAM_PURGE_SECRET env-var gate: if set, callers must supply the value in x-osham-purge-secret header or receive 401 - tests: 9 new cases covering trailing-slash allow/deny, single-star depth enforcement, nested precedence, unknown-key warnings, broad-pattern warning, and purge auth Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- config.reader: add KNOWN_TOP_LEVEL_KEYS set and warn on unknown top-level scalar keys (e.g. 'purges: true' as a typo for 'purge: true') instead of silently treating them as namespace candidates and throwing a confusing error - config.reader: filter namespaceKeys to only object-valued non-reserved keys so typo scalars are skipped cleanly after the warning - test: add two new Config Validation tests covering top-level unknown key warnings and the absence of warnings on all known top-level keys - docs/purge-cache.md: document OSHAM_PURGE_SECRET authentication, explain the broad-pattern warning, and expand the security guidance section Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…es 1+2) Adds /__osham/admin/* route foundation with shared-secret auth middleware (OSHAM_ADMIN_SECRET / x-osham-admin-secret header), plus four config endpoints: GET /__osham/admin/config – return structured IFullConfig + meta POST /__osham/admin/config/validate – validate proposed config, return errors/warnings PUT /__osham/admin/config – validate + atomically save to cache-config.yml POST /__osham/admin/config/reload – re-read file, update in-memory admin state New files: src/admin.state.ts – shared admin state (config, meta, revision) src/middlewares/adminConfig.ts – all admin route handlers Changes: src/config.reader.ts – add validateConfigCollecting() (collects errors/warnings, no throw) src/index.ts – initialise admin state at startup; mount AdminConfig middleware test/index.js – 14 new tests covering auth and all four config endpoints Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Purge page: - Loading state; button disabled while request in flight - Client-side broad-pattern warning (*, **) shown before submit - Confirmation checkbox required for all live (non-dry-run) purges; danger styling when pattern is also broad - Result rendered as structured card (status pill, deleted count, backend warnings) instead of raw JSON dump - Pattern/dryRun changes clear stale result and confirmation state Audit page: - Loading state with disabled Refresh button during fetch - Refresh button to manually re-poll without page reload - Timestamps formatted via toLocaleString() instead of raw ISO - Fifth column "Details" surfaces key fields from AuditEvent.details (pattern + deleted count for purge events, revision for config events) - Result column uses status-pill with enabled/disabled color coding - Empty-state message when no events have been recorded yet Styles: - .purge-warning / .purge-warning--danger alert banners - .purge-result / .purge-result-row structured result card Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR continues the admin UI work after #83.
Included:
Validation run locally:
Follow-up to the earlier admin/API batch PR.