add feedback endpoint (#28) and some other stuff
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m11s
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m11s
This commit is contained in:
18
src/routes/feedback/[...url_hash]/+page.server.ts
Normal file
18
src/routes/feedback/[...url_hash]/+page.server.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { Feedback } from '$lib/server/database';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { env } from '$env/dynamic/public';
|
||||
|
||||
export const load: PageServerLoad = async ({ params }) => {
|
||||
const feedback = await Feedback.findOne({
|
||||
where: { url_hash: params.url_hash }
|
||||
});
|
||||
|
||||
if (!feedback) throw redirect(302, `${env.PUBLIC_BASE_PATH}/`);
|
||||
|
||||
return {
|
||||
draft: feedback.content === null,
|
||||
event: feedback.event,
|
||||
anonymous: feedback.user_id === null
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user