Skip to content

Add an admin endpoint to toggle maintenance mode at runtime #74

Description

@Jagadeeshftw

📌 Description

src/middleware/maintenanceMode.ts exposes a maintenanceMode(enabled) middleware factory, but nothing in src/app.ts/src/routes currently lets an operator flip it without a redeploy. Add an authenticated toggle endpoint.

🧩 Requirements and context

  • Add POST /api/v1/admin/maintenance accepting { enabled: boolean }, gated by the existing apiKeyAuth middleware.
  • The toggle must update the same in-process flag maintenanceMode() reads, taking effect on the next request with no restart.
  • Log the transition through middleware/auditLog.ts including the actor and timestamp.

🛠️ Suggested execution

  • Wire a small in-memory mutable flag module read by maintenanceMode.ts and written by the new route.
  • Add the route under src/routes/ (or extend src/app.ts if routes are kept flat) with apiKeyAuth applied.
  • Add route tests asserting non-maintenance routes start returning 503 immediately after the toggle, and that unauthenticated toggle attempts are rejected.

✅ Acceptance criteria

  • Toggling maintenance mode via the endpoint takes effect without a process restart.
  • The endpoint requires a valid API key.
  • Audit log records who toggled maintenance mode and when.

🔒 Security notes

Restrict the endpoint to the same API key used elsewhere; consider requiring a distinct admin-scoped key if the general API key is broadly distributed.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issueenhancementNew feature or improvementsecuritySecurity hardening

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions