bring server files into project.
This commit is contained in:
16
src/routes/api/games/+server.ts
Normal file
16
src/routes/api/games/+server.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import type { RequestHandler } from "@sveltejs/kit";
|
||||
import { listResponse, singleResponse } from "$lib/server/responseBodies";
|
||||
import { createNewListing } from "$lib/server/modifyListing";
|
||||
import { Game } from "$lib/server/Game";
|
||||
import { games } from "$lib/server/cache";
|
||||
|
||||
export const GET: RequestHandler = (): Response => {
|
||||
return listResponse(games);
|
||||
};
|
||||
|
||||
export const POST: RequestHandler = (): Response => {
|
||||
const newListing = createNewListing(new Game());
|
||||
games.push(newListing);
|
||||
|
||||
return singleResponse(newListing.id);
|
||||
};
|
Reference in New Issue
Block a user