From d7b7bd9667581f9956f22ec402f30ad08fdc5fe8 Mon Sep 17 00:00:00 2001 From: Rahul Gupta Date: Sat, 1 Jun 2024 05:25:12 +0530 Subject: [PATCH] fix: Return 201 when PATCH creates a new resource A PATCH request may end up creating a new resource, in which case a 201 status code should be returned. --- lib/handlers/patch.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/handlers/patch.js b/lib/handlers/patch.js index 8001c9f5..04bcba1e 100644 --- a/lib/handlers/patch.js +++ b/lib/handlers/patch.js @@ -92,6 +92,7 @@ async function patchHandler (req, res, next) { }) // Send the result to the client + res.sendStatus(resourceExists ? 200 : 201) res.send(result) } catch (err) { return next(err)