adds zod API validation
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
import type { Follow } from "$lib/models/follow";
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import { error, json, type RequestEvent } from "@sveltejs/kit";
|
||||
import { NotificationUpdateSchema } from "$lib/models/api/notification_schema";
|
||||
import { Collection, handleError, update } from "$lib/util/api_util";
|
||||
import { json, type RequestEvent } from "@sveltejs/kit";
|
||||
|
||||
|
||||
export async function POST(event: RequestEvent) {
|
||||
const data = await event.request.json()
|
||||
|
||||
try {
|
||||
const r = await pb.collection('notifications').update<Notification>(event.params.id as string, { ...data, seen: true })
|
||||
const r = await update<Comment>(event, NotificationUpdateSchema, Collection.notifications)
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
throw handleError(e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user