mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
20 lines
No EOL
513 B
TypeScript
20 lines
No EOL
513 B
TypeScript
import { error, json } from '@sveltejs/kit';
|
|
import { getGame } from '$lib/utils/db/gameUtils.js';
|
|
|
|
export const GET = async ({ locals, params }) => {
|
|
const game_id = Number(params.id).valueOf();
|
|
|
|
// TODO: Debounce excessive calls and possibly throttle
|
|
if (isNaN(game_id) || !isFinite(game_id)) {
|
|
error(400, { message: 'Invalid game id' });
|
|
}
|
|
|
|
try {
|
|
return json(await getGame(locals, params.id));
|
|
} catch (e) {
|
|
console.error(e);
|
|
return new Response('Could not get games', {
|
|
status: 500
|
|
});
|
|
}
|
|
} |