bring server files into project.
This commit is contained in:
14
src/routes/api/games/[gameid]/+server.ts
Normal file
14
src/routes/api/games/[gameid]/+server.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { games } from "$lib/server/cache";
|
||||
import { notFoundResponse, singleResponse } from "$lib/server/responseBodies";
|
||||
import type { RequestHandler } from "@sveltejs/kit";
|
||||
|
||||
export const GET: RequestHandler = ({ params }): Response => {
|
||||
const id = params["gameid"];
|
||||
const game = games.find(({ id: gid }) => id === gid);
|
||||
|
||||
if (!game) {
|
||||
return notFoundResponse();
|
||||
}
|
||||
|
||||
return singleResponse(game);
|
||||
};
|
Reference in New Issue
Block a user