mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 08:06:56 +00:00
21 lines
676 B
TypeScript
21 lines
676 B
TypeScript
import { error, text } from "@sveltejs/kit";
|
|
import { z } from "zod";
|
|
import { authorize } from "$lib/server/modules/auth";
|
|
import { deleteFile } from "$lib/server/services/file";
|
|
import type { RequestHandler } from "./$types";
|
|
|
|
export const POST: RequestHandler = async ({ locals, params }) => {
|
|
const { userId } = await authorize(locals, "activeClient");
|
|
|
|
const zodRes = z
|
|
.object({
|
|
id: z.coerce.number().int().positive(),
|
|
})
|
|
.safeParse(params);
|
|
if (!zodRes.success) error(400, "Invalid path parameters");
|
|
const { id } = zodRes.data;
|
|
|
|
await deleteFile(userId, id);
|
|
return text("File deleted", { headers: { "Content-Type": "text/plain" } });
|
|
};
|