Add games library with IGDB, file explorer and static files script

This commit is contained in:
SirBlob committed 2026-11-03 00:27:20 -05:00
1 parent a16444451a
commit ec57bd73b3
65 files changed
+2230 -352

No files matched your search

@@ -0,0 +1,24 @@
import { error, json } from '@sveltejs/kit';
import { requireApiKey } from '#lib/server/library/auth';
import { libraryDatabase } from '#lib/server/library/database';
import { readBody } from '#lib/server/library/input';
import { deleteGame, isIgdbId, saveGame } from '#lib/server/library/games';
import type { RequestHandler } from './$types';
function checkedId(igdbId: string): string {
if (!isIgdbId(igdbId)) error(400, `${igdbId} is not an IGDB ID`);
return igdbId;
}
export const PUT: RequestHandler = async ({ params, request }) => {
requireApiKey(request);
const igdbId = checkedId(params.igdbId);
return json(await saveGame(await libraryDatabase(), igdbId, await readBody(request)));
};
export const DELETE: RequestHandler = async ({ params, request }) => {
requireApiKey(request);
const igdbId = checkedId(params.igdbId);
if (!deleteGame(await libraryDatabase(), igdbId)) error(404, `${igdbId} is not listed`);
return new Response(null, { status: 204 });
};