Create GME list endpoint

This commit is contained in:
2023-10-19 16:49:41 -04:00
parent ce9160a771
commit bef8f6f7ea

16
functions/api/gme/list.ts Normal file
View File

@ -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",
},
});
}