Skip to content

Register Missing Backend API Routes for Frontend #292

@ElioNeto

Description

@ElioNeto

Register Missing Backend API Routes

Several endpoints needed by the Angular frontend do not exist in the backend. These need to be registered to make existing frontend pages functional.

Endpoints to Create

1. Batch Key Insert

POST /keys/batch
Content-Type: application/json

Body: { "records": [{ "key": "k1", "value": "v1" }, ...] }

Response: { "status": "ok", "inserted": 42 }
  • Uses existing Engine::put_cf in a loop (or WAL group commit if available)
  • Must respect rate limits and auth

2. Search Keys

GET /keys/search?q={query}&prefix={bool}&cursor={str}&limit={n}

Response: { "keys": [...], "cursor": "..." }
  • When prefix=true: delegate to Engine::search_prefix
  • When prefix=false: substring match (scan + filter)
  • Cursor-based pagination

3. Full Scan

GET /scan?limit={n}&cursor={str}

Response: { "records": [{ "key": "...", "value": "..." }], "cursor": "..." }
  • Delegates to Engine::scan_cf("default", None, None, Some(limit))

4. POST /keys (alternative to PUT)

POST /keys
Content-Type: application/json

Body: { "key": "mykey", "value": "myvalue" }

Response: { "status": "ok" }
  • Convenience wrapper, same as PUT /keys/{key}

5. Feature Flags API

GET    /features              — List all feature flags
POST   /features/{name}       — Create/update a feature flag
DELETE /features/{name}       — Delete a feature flag
  • The src/features/ module exists but is a placeholder
  • Create proper feature flag storage and API

6. Token Management API

GET    /admin/tokens           — List all tokens (with metadata)
POST   /admin/tokens           — Create a new token
DELETE /admin/tokens/{id}      — Revoke a token
  • TokenManager in src/api/auth/manager.rs exists but has no REST routes
  • Wire up the existing token CRUD methods to HTTP handlers

Implementation Notes

  • All endpoints must use existing auth middleware (HttpAuthentication::bearer)
  • All endpoints must respect rate limiting
  • Follow existing patterns in src/api/mod.rs
  • Add proper error handling and status codes
  • Write integration tests for each new endpoint

Acceptance Criteria

  • POST /keys/batch works with valid and invalid records
  • GET /keys/search?q= returns matching keys with pagination
  • GET /scan returns all key-value pairs
  • POST /keys works as alternative to PUT
  • Feature flags API fully CRUD
  • Token management API fully CRUD
  • All endpoints return proper error responses
  • Integration tests for each endpoint

Parent Epic

#290

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions