From d36b8f7a7c2b9c52c71a9b4ecfbd586ec9ceae07 Mon Sep 17 00:00:00 2001 From: Darius Jankauskas Date: Fri, 28 Jul 2023 17:59:07 -0400 Subject: [PATCH] todomvc: consistent first item uuid --- todomvc/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/todomvc/src/index.ts b/todomvc/src/index.ts index 992d120d..3333b7dc 100644 --- a/todomvc/src/index.ts +++ b/todomvc/src/index.ts @@ -36,7 +36,10 @@ app.get("/items", (req, res) => { app.post("/items", (req, res) => { // Note: no validation here! - const id = crypto.randomUUID(); + const id = + items.size === 0 + ? "ed76baac-7b44-4a11-b345-56384ffa8ad8" + : crypto.randomUUID(); console.log("got body", req.body); const newItem = { id, ...req.body }; items.set(id, newItem);