Files
portal/src/routes/api/v1/affirmations/+server.ts
T
2026-02-20 10:25:55 -06:00

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
})
);
};