From be2ac5fe4a0d0b87ebe12853a1dd8b459ce369c1 Mon Sep 17 00:00:00 2001 From: Alex Pooley Date: Wed, 19 Mar 2025 05:14:20 +0000 Subject: refactor: rename context variable for clarity in route handlers --- source/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/index.js b/source/index.js index c20041b..5fe6c8b 100644 --- a/source/index.js +++ b/source/index.js @@ -7,22 +7,22 @@ const app = new Hono(); app.use("*", cors()); // return a simple message -app.get("/", (c) => { - return c.json({ +app.get("/", (context) => { + return context.json({ message: "Hello, World! :3", }); }); // return own status of the server -app.get("/status", (c) => { - return c.json({ +app.get("/status", (context) => { + return context.json({ status: "ok", }); }); // return status of a given service -app.get("/status/:service", (c) => { - const { service } = c.req.param(); +app.get("/status/:service", (context) => { + const { service } = context.req.param(); const acceptedServices = [ "dns", @@ -44,7 +44,7 @@ app.get("/status/:service", (c) => { ]; if (!acceptedServices.includes(service)) { - return c.json( + return context.json( { error: "unknown service", }, @@ -52,7 +52,7 @@ app.get("/status/:service", (c) => { ); } - return c.json({ + return context.json({ status: "ok", }); }); -- cgit v1.2.3