- 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
33 lines
889 B
TypeScript
33 lines
889 B
TypeScript
import { Elysia, t } from "elysia"
|
|
import { ensureSteamGame } from "@/lib/steam/sync"
|
|
|
|
export const gameStubRoutes = new Elysia({ prefix: "/games", detail: { tags: ["Games"] } }).post(
|
|
"/stub",
|
|
async ({ body, set }) => {
|
|
const result = await ensureSteamGame(body.steamAppId)
|
|
|
|
if (!result.game) {
|
|
set.status = 500
|
|
return { error: "Failed to create or retrieve game" }
|
|
}
|
|
|
|
// If game already existed, return 200 with created:false
|
|
if (!result.created) {
|
|
return { game: result.game, created: false }
|
|
}
|
|
|
|
// If sync failed but stub exists, still return 201 with error info
|
|
if (result.error) {
|
|
set.status = 201
|
|
return { game: result.game, created: true, syncError: result.error }
|
|
}
|
|
|
|
set.status = 201
|
|
return { game: result.game, created: true }
|
|
},
|
|
{
|
|
body: t.Object({
|
|
steamAppId: t.Number(),
|
|
}),
|
|
},
|
|
) |