boredgame/src/routes/game/[id]/+page.server.ts

25 lines
466 B
TypeScript
Raw Normal View History

2022-08-26 05:06:39 +00:00
import { error } from '@sveltejs/kit';
import prisma from '$lib/prisma.js';
import { boardGameApi } from '../../api';
2022-04-20 02:15:46 +00:00
export const load = async ({ params, setHeaders, locals }) => {
try {
const { user } = locals;
const { id } = params;
const game = await prisma.game.findUnique({
where: {
id
}
});
console.log('found game', game);
return {
game,
user
};
} catch (error) {
console.log(error);
}
2022-04-20 02:15:46 +00:00
throw error(404, 'not found');
2022-07-28 00:05:54 +00:00
};