From bef8f6f7ea5f8272c0c4008cfee0b0b963537fba Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:49:41 -0400 Subject: [PATCH] Create GME list endpoint --- functions/api/gme/list.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 functions/api/gme/list.ts diff --git a/functions/api/gme/list.ts b/functions/api/gme/list.ts new file mode 100644 index 0000000..84851f9 --- /dev/null +++ b/functions/api/gme/list.ts @@ -0,0 +1,16 @@ +export async function onRequestGet(context: RequestContext) { + const list = await context.env.DATA.list({ prefix: "gamemod_" }); + const entries = []; + + for (const key of list.keys) + entries.push({ + metadata: key.metadata, + user: key.name.replace("gamemod_", ""), + }); + + return new Response(JSON.stringify(entries), { + headers: { + "content-type": "application/json", + }, + }); +}