feat: add OpenAPI support and in-process cron scheduler

- Install @elysia/openapi to auto-generate API docs at /api/openapi
- Install @elysia/cron for in-process scheduled jobs (orphan detection at 2am, storage cleanup at 3am)
- Add Scalar UI docs with 14 tag groups and Bearer JWT security scheme
- Add route-level detail annotations (tags, summaries) to all 30+ route files
- Upgrade crud-builder to accept optional tags config
- Keep HTTP cron endpoint as manual/admin fallback
This commit is contained in:
2026-05-14 21:43:33 +08:00
parent 20f010cef1
commit fbfc43832e
37 changed files with 161 additions and 32 deletions
+9 -2
View File
@@ -10,6 +10,7 @@ import { requireRole } from "@/lib/auth/guard"
export const gamesRoutes = createCrudRoutes(games, {
prefix: "/games",
name: "Game",
tags: ["Games"],
auth: { read: "public", write: "contributor", delete: "admin" },
search: { fields: ["title", "developer", "publisher"] },
filter: { fields: ["source", "onlineMultiplayerStatus", "syncStatus"] },
@@ -17,7 +18,10 @@ export const gamesRoutes = createCrudRoutes(games, {
})
// ── Game Versions (nested under /games/:gameId/versions) ──────────
export const gameVersionsRoutes = new Elysia({ prefix: "/games/:gameId/versions" })
export const gameVersionsRoutes = new Elysia({
prefix: "/games/:gameId/versions",
detail: { tags: ["Games"] },
})
// LIST versions for a game
.get(
"/",
@@ -192,7 +196,10 @@ export const gameVersionsRoutes = new Elysia({ prefix: "/games/:gameId/versions"
const MAX_BULK_SYNC = 1000
export const gameSyncRoutes = new Elysia({ prefix: "/games" })
export const gameSyncRoutes = new Elysia({
prefix: "/games",
detail: { tags: ["Admin"] },
})
// Bulk sync with streaming progress (defined before /:gameId/sync to avoid route conflict)
.post(
"/sync/bulk",