From 680d91689493eab5d83c19c9da66655a190618f9 Mon Sep 17 00:00:00 2001
From: regalijan <r@regalijan.com>
Date: Thu, 19 Oct 2023 16:49:53 -0400
Subject: [PATCH] Insert id property into return data

---
 functions/api/mod-queue/list.ts | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/functions/api/mod-queue/list.ts b/functions/api/mod-queue/list.ts
index 71aed33..8a86a90 100644
--- a/functions/api/mod-queue/list.ts
+++ b/functions/api/mod-queue/list.ts
@@ -47,7 +47,6 @@ export async function onRequestGet(context: RequestContext) {
   const prefix = types[entryType];
   const table = tables[entryType];
   const items = [];
-  console.log(!showClosed)
   const { results }: { results?: { created_at: number; id: string }[] } =
     /*
       This is normally VERY BAD and can lead to injection attacks
@@ -62,9 +61,11 @@ export async function onRequestGet(context: RequestContext) {
 
   if (results)
     for (const { id } of results) {
-      items.push(
-        await context.env.DATA.get(`${prefix}_${id}`, { type: "json" })
-      );
+      const item = await context.env.DATA.get(`${prefix}_${id}`, {
+        type: "json",
+      });
+
+      if (item) items.push({ ...item, id });
     }
 
   return new Response(JSON.stringify(items.filter((v) => v !== null)), {