From f960ccc5daff438ac1e0ee738557afeea4f2ed92 Mon Sep 17 00:00:00 2001 From: Braden Wong <13159333+braden-w@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:45:37 -0800 Subject: [PATCH 1/3] docs(essential): clarify status accepts both number and string names - Remove '// or' comments from teapot examples - Add explanatory note about 418 = 'I'm a teapot' with link to status tutorial - Use status("Unauthorized") for auth examples (clearer than 401) --- docs/essential/life-cycle.md | 4 ++-- docs/patterns/error-handling.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/essential/life-cycle.md b/docs/essential/life-cycle.md index 9d8b49bd..5b0404c5 100644 --- a/docs/essential/life-cycle.md +++ b/docs/essential/life-cycle.md @@ -502,7 +502,7 @@ import { validateSession } from './user' new Elysia() .get('/', () => 'hi', { beforeHandle({ set, cookie: { session }, status }) { - if (!validateSession(session.value)) return status(401) + if (!validateSession(session.value)) return status("Unauthorized") } }) .listen(3000) @@ -527,7 +527,7 @@ new Elysia() .guard( { beforeHandle({ set, cookie: { session }, status }) { - if (!validateSession(session.value)) return status(401) + if (!validateSession(session.value)) return status("Unauthorized") } }, (app) => diff --git a/docs/patterns/error-handling.md b/docs/patterns/error-handling.md index 7ad6e6a2..454fc273 100644 --- a/docs/patterns/error-handling.md +++ b/docs/patterns/error-handling.md @@ -308,6 +308,8 @@ new Elysia() }) ``` +Here we use `status(418)` which is the "I'm a teapot" status code. You can also use the string name directly: `status("I'm a teapot")`. See [Status and Headers](/tutorial/getting-started/status-and-headers) for more on using status codes. + From 2d2207ca81ca0678fcac1fcbb8992d325925ae23 Mon Sep 17 00:00:00 2001 From: Braden Wong Date: Fri, 5 Dec 2025 17:30:35 -0800 Subject: [PATCH 2/3] style: use single quotes for status strings --- docs/essential/life-cycle.md | 4 ++-- docs/patterns/error-handling.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/essential/life-cycle.md b/docs/essential/life-cycle.md index 5b0404c5..74c72906 100644 --- a/docs/essential/life-cycle.md +++ b/docs/essential/life-cycle.md @@ -502,7 +502,7 @@ import { validateSession } from './user' new Elysia() .get('/', () => 'hi', { beforeHandle({ set, cookie: { session }, status }) { - if (!validateSession(session.value)) return status("Unauthorized") + if (!validateSession(session.value)) return status('Unauthorized') } }) .listen(3000) @@ -527,7 +527,7 @@ new Elysia() .guard( { beforeHandle({ set, cookie: { session }, status }) { - if (!validateSession(session.value)) return status("Unauthorized") + if (!validateSession(session.value)) return status('Unauthorized') } }, (app) => diff --git a/docs/patterns/error-handling.md b/docs/patterns/error-handling.md index 454fc273..f9e86361 100644 --- a/docs/patterns/error-handling.md +++ b/docs/patterns/error-handling.md @@ -308,7 +308,7 @@ new Elysia() }) ``` -Here we use `status(418)` which is the "I'm a teapot" status code. You can also use the string name directly: `status("I'm a teapot")`. See [Status and Headers](/tutorial/getting-started/status-and-headers) for more on using status codes. +Here we use `status(418)` which is the "I'm a teapot" status code. You can also use the string name directly: `status('I\'m a teapot')`. See [Status and Headers](/tutorial/getting-started/status-and-headers) for more on using status codes. Date: Fri, 5 Dec 2025 17:39:31 -0800 Subject: [PATCH 3/3] style: use double quotes for strings with apostrophes --- docs/patterns/error-handling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/patterns/error-handling.md b/docs/patterns/error-handling.md index f9e86361..454fc273 100644 --- a/docs/patterns/error-handling.md +++ b/docs/patterns/error-handling.md @@ -308,7 +308,7 @@ new Elysia() }) ``` -Here we use `status(418)` which is the "I'm a teapot" status code. You can also use the string name directly: `status('I\'m a teapot')`. See [Status and Headers](/tutorial/getting-started/status-and-headers) for more on using status codes. +Here we use `status(418)` which is the "I'm a teapot" status code. You can also use the string name directly: `status("I'm a teapot")`. See [Status and Headers](/tutorial/getting-started/status-and-headers) for more on using status codes.