mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-14 00:31:25 +10:00
more client routes to support Drop app update
This commit is contained in:
15
server/api/v1/client/object/[id]/index.get.ts
Normal file
15
server/api/v1/client/object/[id]/index.get.ts
Normal 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;
|
||||
});
|
||||
Reference in New Issue
Block a user