16 lines
376 B
TypeScript
16 lines
376 B
TypeScript
import { error } from '@sveltejs/kit';
|
|
import type { RequestHandler } from './$types';
|
|
import { prisma } from '$lib/db';
|
|
|
|
export const GET: RequestHandler = async () => {
|
|
const affirmations = await prisma.affirmation.findMany();
|
|
if (!affirmations) {
|
|
throw error(500, 'unable to fetch affirmations');
|
|
}
|
|
return new Response(
|
|
JSON.stringify({
|
|
affirmations
|
|
})
|
|
);
|
|
};
|