Routes call ensureSave first (mission functions assume an initialized save), map MissionError to 404/409 and non-integer path ids to 400. OpenAPI spec in code gains both paths + the Mission schema (12 -> 14 paths); openapi.test.ts covers the new shapes.
11 lines
408 B
TypeScript
11 lines
408 B
TypeScript
import { getGameDb } from '@/lib/db/client'
|
|
import { ensureSave } from '@/lib/game/save'
|
|
import { getMissions } from '@/lib/game/missions'
|
|
|
|
// The full mission board for the single active save; auto-initializes on first hit.
|
|
export async function GET() {
|
|
const db = await getGameDb()
|
|
await ensureSave(db) // top-up inside getMissions assumes a save exists
|
|
return Response.json(await getMissions(db))
|
|
}
|