{
  "generatedAt": "2026-12-03T03:33:31.019Z",
  "baseUrls": {
    "production": "https://api.feefer.net",
    "local": "http://localhost:3000"
  },
  "roles": [
    {
      "name": "user",
      "priority": 0
    },
    {
      "name": "support",
      "priority": 1
    },
    {
      "name": "moderator",
      "priority": 2
    },
    {
      "name": "admin",
      "priority": 3
    },
    {
      "name": "owner",
      "priority": 4
    }
  ],
  "sections": [
    {
      "id": "base",
      "title": "Base routes",
      "endpoints": [
        {
          "method": "GET",
          "path": "/",
          "summary": "Process liveness.",
          "auth": "none",
          "request": null,
          "response": "{\n  \"status\": 200,\n  \"message\": \"🦊 The API is up!\",\n  \"docs\": \"/docs\"\n}",
          "notes": []
        },
        {
          "method": "GET",
          "path": "/health",
          "summary": "Process liveness; does not check dependencies.",
          "auth": "none",
          "request": null,
          "response": "{\n  \"status\": 200,\n  \"message\": \"API is up! (Duh). 🦊\",\n  \"timestamp\": \"2026-01-01T00:00:00.000Z\",\n  \"uptimeSeconds\": 1234.56,\n  \"responseTimeMs\": 0\n}",
          "notes": [
            "Liveness only; /ready checks database migrations and storage. Both probes are exempt from traffic quotas."
          ]
        },
        {
          "method": "GET",
          "path": "/ready",
          "summary": "Dependency and migration readiness; returns 503 while unavailable or stopping.",
          "auth": "none",
          "request": null,
          "response": "{\n  \"status\": 200,\n  \"ready\": true\n}",
          "notes": [
            "Returns 503 when dependencies are unavailable, migrations are pending, or shutdown has begun."
          ]
        },
        {
          "method": "GET",
          "path": "/docs",
          "summary": "Browser documentation.",
          "auth": "none",
          "request": null,
          "response": "<html>...</html>",
          "notes": []
        },
        {
          "method": "GET",
          "path": "/docs.md",
          "summary": "Markdown reference.",
          "auth": "none",
          "request": null,
          "response": "# Feefer API reference\n...",
          "notes": []
        },
        {
          "method": "GET",
          "path": "/docs.json",
          "summary": "Legacy endpoint catalog.",
          "auth": "none",
          "request": null,
          "response": "{\n  \"generatedAt\": \"2026-01-01T00:00:00.000Z\",\n  \"baseUrls\": {},\n  \"roles\": [],\n  \"sections\": []\n}",
          "notes": [
            "Compatibility endpoint catalog. Use /openapi.json for schemas and client generation."
          ]
        },
        {
          "method": "GET",
          "path": "/openapi.json",
          "summary": "OpenAPI 3.1 specification generated from route schemas.",
          "auth": "none",
          "request": null,
          "response": "{\n  \"openapi\": \"3.1.0\",\n  \"info\": {\n    \"title\": \"Feefer API\",\n    \"version\": \"3.0.0\"\n  },\n  \"paths\": {}\n}",
          "notes": [
            "Generated from the same contract objects and Zod request schemas mounted by the routers."
          ]
        }
      ]
    },
    {
      "id": "auth",
      "title": "Auth routes",
      "endpoints": [
        {
          "method": "POST",
          "path": "/auth/register",
          "summary": "Create a user and issue an access token.",
          "auth": "none",
          "request": "{\n  \"username\": \"example_user\",\n  \"password\": \"choose-a-long-password\"\n}",
          "response": "{\n  \"user\": {\n    \"id\": \"user_id\",\n    \"username\": \"example_user\",\n    \"role\": \"user\",\n    \"banned\": false\n  },\n  \"accessToken\": \"Bearer eyJhbGciOi...\"\n}",
          "notes": [
            "Username must match [a-zA-Z0-9_.-]{3,32}; it is trimmed and case-preserving. Password must be a nonempty string.",
            "Returns 201. Use the entire accessToken value, including its Bearer prefix.",
            "Rate limited to 3 registrations per hour per IP."
          ]
        },
        {
          "method": "POST",
          "path": "/auth/login",
          "summary": "Validate credentials and replace the active access token.",
          "auth": "none",
          "request": "{\n  \"username\": \"example_user\",\n  \"password\": \"choose-a-long-password\"\n}",
          "response": "{\n  \"user\": {\n    \"id\": \"user_id\",\n    \"username\": \"example_user\",\n    \"role\": \"user\",\n    \"banned\": false\n  },\n  \"accessToken\": \"Bearer eyJhbGciOi...\"\n}",
          "notes": [
            "Each login issues a unique JWT and replaces the stored token hash. Older access tokens are revoked.",
            "Tokens expire after ACCESS_TOKEN_TTL (default 30d). No refresh or logout endpoint exists.",
            "Successful logins are excluded once from login-specific quotas; global/auth-group quotas and slowdown still apply."
          ]
        }
      ]
    },
    {
      "id": "admin",
      "title": "Admin user routes",
      "endpoints": [
        {
          "method": "POST",
          "path": "/admin/ban",
          "summary": "Ban a lower-priority user.",
          "auth": "admin+",
          "request": "{\n  \"userId\": \"user_id\"\n}",
          "response": "{\n  \"status\": 200,\n  \"message\": \"User example_user has been banned\",\n  \"user\": {\n    \"id\": \"user_id\",\n    \"username\": \"example_user\",\n    \"role\": \"user\",\n    \"banned\": true\n  }\n}",
          "notes": []
        },
        {
          "method": "GET",
          "path": "/admin/user/search",
          "summary": "Find a user by userId or username; userId takes precedence.",
          "auth": "support+",
          "request": null,
          "response": "{\n  \"status\": 200,\n  \"user\": {\n    \"id\": \"user_id\",\n    \"username\": \"example_user\",\n    \"role\": \"user\",\n    \"banned\": false,\n    \"createdAt\": \"2026-01-01T00:00:00.000Z\",\n    \"updatedAt\": \"2026-01-01T00:00:00.000Z\",\n    \"collection\": \"users\"\n  },\n  \"requests\": {\n    \"id\": \"user_id\",\n    \"auth\": 0,\n    \"admin\": 0,\n    \"images\": 12,\n    \"total\": 12,\n    \"createdAt\": \"2026-01-01T00:00:00.000Z\",\n    \"updatedAt\": \"2026-01-01T00:00:00.000Z\",\n    \"collection\": \"requests\"\n  }\n}",
          "notes": [
            "Pass ?userId=... or ?username=...; userId takes precedence.",
            "requests is null if the user has no counter row."
          ]
        },
        {
          "method": "GET",
          "path": "/admin/users",
          "summary": "Cursor-paginated users with their counters.",
          "auth": "admin+",
          "request": null,
          "response": "{\n  \"status\": 200,\n  \"users\": {\n    \"example_user\": {\n      \"user\": {\n        \"id\": \"user_id\",\n        \"username\": \"example_user\",\n        \"role\": \"user\",\n        \"banned\": false,\n        \"createdAt\": \"2026-01-01T00:00:00.000Z\",\n        \"updatedAt\": \"2026-01-01T00:00:00.000Z\",\n        \"collection\": \"users\"\n      },\n      \"requests\": {\n        \"id\": \"user_id\",\n        \"auth\": 0,\n        \"admin\": 0,\n        \"images\": 12,\n        \"total\": 12,\n        \"createdAt\": \"2026-01-01T00:00:00.000Z\",\n        \"updatedAt\": \"2026-01-01T00:00:00.000Z\",\n        \"collection\": \"requests\"\n      }\n    }\n  },\n  \"pagination\": {\n    \"limit\": 100,\n    \"nextCursor\": null\n  }\n}",
          "notes": [
            "Pass ?limit=100 and an optional cursor from pagination.nextCursor. Limit is 1–1000; default 100.",
            "Each page is keyed by username and ordered by creation time and ID. A null nextCursor marks the last page."
          ]
        },
        {
          "method": "GET",
          "path": "/admin/users/dashboard",
          "summary": "Cursor-paginated user rows and totals across all users.",
          "auth": "admin+",
          "request": null,
          "response": "{\n  \"status\": 200,\n  \"summary\": {\n    \"totalUsers\": 1,\n    \"bannedUsers\": 0,\n    \"totalRequests\": 12,\n    \"adminRequests\": 0,\n    \"authRequests\": 0,\n    \"imageRequests\": 12\n  },\n  \"pagination\": {\n    \"limit\": 100,\n    \"nextCursor\": null\n  },\n  \"users\": [\n    {\n      \"id\": \"user_id\",\n      \"username\": \"example_user\",\n      \"role\": \"user\",\n      \"banned\": false,\n      \"createdAt\": \"2026-01-01T00:00:00.000Z\",\n      \"updatedAt\": \"2026-01-01T00:00:00.000Z\",\n      \"collection\": \"users\",\n      \"requestsId\": \"user_id\",\n      \"auth\": 0,\n      \"admin\": 0,\n      \"images\": 12,\n      \"total\": 12,\n      \"requestsCreatedAt\": \"2026-01-01T00:00:00.000Z\",\n      \"requestsUpdatedAt\": \"2026-01-01T00:00:00.000Z\",\n      \"requestsCollection\": \"requests\"\n    }\n  ]\n}",
          "notes": [
            "User rows are paginated using limit/cursor. Summary totals always cover every user, including users outside the current page.",
            "The current authorized admin request is counted before the dashboard is read."
          ]
        },
        {
          "method": "POST",
          "path": "/admin/user/edit/role",
          "summary": "Change a role; actor must outrank target and granted role.",
          "auth": "admin+",
          "request": "{\n  \"userId\": \"user_id\",\n  \"role\": \"support\"\n}",
          "response": "{\n  \"status\": 200,\n  \"message\": \"User example_user has been changed to support\",\n  \"user\": {\n    \"id\": \"user_id\",\n    \"username\": \"example_user\",\n    \"role\": \"support\",\n    \"banned\": false\n  }\n}",
          "notes": [
            "Valid roles: user, support, moderator, admin, owner. The actor must strictly outrank the target and the granted role."
          ]
        },
        {
          "method": "POST",
          "path": "/admin/user/edit/username",
          "summary": "Rename a lower-priority user.",
          "auth": "admin+",
          "request": "{\n  \"userId\": \"user_id\",\n  \"newUsername\": \"new_name\"\n}",
          "response": "{\n  \"status\": 200,\n  \"message\": \"User username has been changed to new_name\",\n  \"user\": {\n    \"id\": \"user_id\",\n    \"username\": \"new_name\",\n    \"role\": \"user\",\n    \"banned\": false\n  }\n}",
          "notes": []
        }
      ]
    },
    {
      "id": "s3",
      "title": "Admin S3 routes",
      "endpoints": [
        {
          "method": "GET",
          "path": "/admin/s3/test",
          "summary": "Check a bucket using the optional bucketExists query parameter.",
          "auth": "admin+",
          "request": null,
          "response": "{\n  \"status\": 200,\n  \"bucketExists\": true\n}",
          "notes": [
            "Use ?bucketExists=lunar-api to check storage; no parameter returns a route smoke test.",
            "Legacy GET JSON bodies remain accepted. New clients should use query parameters."
          ]
        },
        {
          "method": "POST",
          "path": "/admin/s3/upload",
          "summary": "Upload up to 10 MiB of raw image bytes.",
          "auth": "admin+",
          "request": null,
          "response": "{\n  \"status\": 200,\n  \"message\": \"Image uploaded successfully\",\n  \"bucketName\": \"lunar-api\",\n  \"objectName\": \"fox/example.png\",\n  \"etag\": \"example-etag\",\n  \"versionId\": null\n}",
          "notes": [
            "Supply bucketName and objectName as query parameters. Send raw image/* bytes, up to 10 MiB.",
            "A successful upload invalidates this process’s cached category catalogs for the bucket."
          ]
        },
        {
          "method": "DELETE",
          "path": "/admin/s3/delete",
          "summary": "Delete by objectName or etag; objectName takes precedence.",
          "auth": "admin+",
          "request": "{\n  \"bucketName\": \"lunar-api\",\n  \"objectName\": \"fox/example.png\"\n}",
          "response": "{\n  \"status\": 200,\n  \"message\": \"Object deleted successfully\",\n  \"bucketName\": \"lunar-api\",\n  \"object\": \"fox/example.png\"\n}",
          "notes": [
            "objectName takes precedence over etag. An absent etag match returns 404.",
            "A successful delete invalidates this process’s cached category catalogs for the bucket."
          ]
        }
      ]
    },
    {
      "id": "images",
      "title": "Image routes",
      "endpoints": [
        {
          "method": "GET",
          "path": "/images/{folder}/random",
          "summary": "Choose random image metadata from a cached category catalog.",
          "auth": "user",
          "request": null,
          "response": "{\n  \"name\": \"fox/example.png\",\n  \"etag\": \"example-etag\",\n  \"size\": 123456,\n  \"lastModified\": \"2026-01-01T00:00:00.000Z\",\n  \"url\": \"https://api.feefer.net/i/fox/example.png\"\n}",
          "notes": [
            "Folders: fox, bird, shibe, weiner-dog, slap, hug, kiss, smug, pat.",
            "Catalogs are cached for IMAGE_CATALOG_TTL_MS (default 60 seconds); concurrent refreshes share one listing.",
            "Only direct keys with proxy-compatible filenames are returned. Empty categories return 503.",
            "IMAGE_CDN_BASE_URL can point URLs directly to public storage/CDN; otherwise URLs use PUBLIC_BASE_URL/i/."
          ]
        },
        {
          "method": "GET",
          "path": "/i/{folder}/{filename}",
          "summary": "Public image stream with a 25 MiB delivery limit.",
          "auth": "none",
          "request": null,
          "response": "binary image bytes",
          "notes": [
            "Public: no token or per-user counter. Allowed folders: fox, bird, shibe, weiner-dog, slap, hug, kiss, smug, pat.",
            "Filenames allow letters, numbers, dots, underscores, and hyphens; .. and nested paths are rejected.",
            "Streams from IMAGE_SOURCE_BASE_URL with redirects disabled, timeouts, and an enforced 25 MiB byte limit.",
            "Cache-Control: public, max-age=3600. Missing source objects return 404; other source failures return 502."
          ]
        }
      ]
    }
  ]
}