17 lines
533 B
TypeScript
17 lines
533 B
TypeScript
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);
|
|
};
|