Build user pages
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
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
|
||||
})
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { prisma } from '$lib/db';
|
||||
|
||||
export const GET: RequestHandler = async ({ url }) => {
|
||||
const key = url.searchParams.get('key') ?? '';
|
||||
const email = url.searchParams.get('email') ?? '';
|
||||
|
||||
if (key === '' || email === '') {
|
||||
const proclamations = await prisma.proclamation.findMany();
|
||||
if (!proclamations) {
|
||||
throw error(500, 'unable to fetch proclamations');
|
||||
}
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
proclamations
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Check that the key exists
|
||||
// Check that the email exists
|
||||
// Check that the email belongs to a user
|
||||
// Check that the key belongs to the user
|
||||
// Write a helper function for this
|
||||
// Return all proclamations attached to the user
|
||||
|
||||
return new Response(JSON.stringify({ error: 'not implemented' }), { status: 501 });
|
||||
};
|
||||
Reference in New Issue
Block a user