20 lines
510 B
TypeScript
20 lines
510 B
TypeScript
import { games } from "$lib/server/cache";
|
|
import { badRequestResponse, notFoundResponse, singleResponse } from "$lib/server/responseBodies";
|
|
import type { RequestHandler } from "@sveltejs/kit";
|
|
|
|
export const GET: RequestHandler = ({ params }): Response => {
|
|
const id = params["gameid"];
|
|
|
|
if (!id) {
|
|
return badRequestResponse("missing gameid parameter");
|
|
}
|
|
|
|
const game = games.find(({ id: gid }) => id === gid.toString());
|
|
|
|
if (!game) {
|
|
return notFoundResponse();
|
|
}
|
|
|
|
return singleResponse(game);
|
|
};
|