more client routes to support Drop app update

This commit is contained in:
DecDuck
2024-10-15 20:05:38 +11:00
parent 329c74d3ce
commit 91b7e1071c
4 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,15 @@
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
export default defineClientEventHandler(async (h3, utils) => {
const id = getRouterParam(h3, "id");
if (!id) throw createError({ statusCode: 400, statusMessage: "Invalid ID" });
const user = await utils.fetchUser();
const object = await h3.context.objects.fetchWithPermissions(id, user.id);
if (!object)
throw createError({ statusCode: 404, statusMessage: "Object not found" });
setHeader(h3, "Content-Type", object.mime);
return object.data;
});