Skip to content

Conversation

@braden-w
Copy link
Contributor

@braden-w braden-w commented Dec 6, 2025

This PR completes the conversion of numeric status codes to descriptive string names across the remaining documentation files, building on the work started in PRs #739-#743 and complemented by #745. Together, these changes improve the visibility and readability of string status names throughout the Elysia documentation.

The primary motivation for this change is consistency and self-documentation. Status names like "Unauthorized" and "Bad Request" are immediately readable without requiring developers to recall HTTP status code numbers, making the documentation more accessible and the code more maintainable. This conversion affects the homepage examples, Better Auth integration guide, extends-context pattern documentation, and Eden Treaty response examples.

Some numeric codes were intentionally preserved where they serve a specific purpose. The 418 teapot examples remain numeric with explanatory notes since the teapot status is inherently playful and often referenced by its number. Similarly, 404 codes in routing examples were kept because they're self-explanatory in that context, and migration guides retain their original numeric codes to ensure accurate framework comparison for developers coming from other ecosystems.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 6, 2025

Warning

Rate limit exceeded

@braden-w has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 21 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 7b88bc9 and 05c2a70.

📒 Files selected for processing (5)
  • docs/eden/treaty/response.md (2 hunks)
  • docs/index.md (3 hunks)
  • docs/integrations/better-auth.md (1 hunks)
  • docs/patterns/extends-context.md (1 hunks)
  • docs/tutorial/patterns/extends-context/index.md (1 hunks)

Walkthrough

Documentation examples across multiple guides were updated to demonstrate string-based HTTP status usage instead of numeric codes. Additionally, clarifications on status string syntax were added to status/headers and error-handling documentation. No functional code changes or API modifications.

Changes

Cohort / File(s) Summary
Status Code String Replacements in Essential Guides
docs/essential/best-practice.md, docs/essential/life-cycle.md, docs/essential/plugin.md, docs/key-concept.md, docs/eden/treaty/response.md, docs/integrations/better-auth.md
Updated example code to use string status names (e.g., status("Unauthorized")) instead of numeric HTTP codes (e.g., status(401)) across authorization and validation scenarios.
Status Code String Replacements in Tutorial Examples
docs/tutorial/getting-started/encapsulation/data.ts, docs/tutorial/getting-started/encapsulation/index.md, docs/tutorial/getting-started/guard/index.md, docs/tutorial/getting-started/life-cycle/index.md, docs/tutorial/getting-started/validation/index.md, docs/tutorial/patterns/extends-context/index.md, docs/tutorial/patterns/macro/index.md, docs/tutorial/patterns/error-handling/index.md
Replaced numeric status codes with string descriptors in beforeHandle hooks, guards, and handlers (401 → "Unauthorized", 403 → "Forbidden", 418 → "I'm a teapot").
Status Code String Replacements in Overview & Patterns
docs/index.md, docs/patterns/extends-context.md, docs/patterns/error-handling.md
Updated inline examples and code snippets to use string-based status calls instead of numeric codes.
Status/Headers Documentation Enhancement
docs/tutorial/getting-started/status-and-headers/index.md
Added clarification that status() can be invoked with numeric codes or string status names; documented TypeScript autocompletion support for string variants; fixed syntax typo in "I'm a teapot" example.
Error Handling Pattern Documentation
docs/tutorial/getting-started/life-cycle/index.md
Added explanatory paragraph on status(418) and string form status("I'm a teapot") usage; linked to Status documentation reference.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • High repetition: The majority of changes follow a consistent pattern of numeric → string status code replacements across many files, reducing cognitive load per file.
  • Areas requiring attention:
    • Verify that all status code replacements are semantically correct (401 → "Unauthorized", 403 → "Forbidden", etc.)
    • Confirm syntax fixes (e.g., the "I'm a teapot" typo correction) don't introduce new errors
    • Check that added documentation text flows naturally and links are valid

Poem

🐰 Status strings hop into place so bright,
No more numeric codes, just words that feel right,
From 401 to Unauthorized we go,
Doc examples dance with a cleaner flow!
String-based statuses, TypeScript's delight! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately reflects the main objective: converting numeric HTTP status codes to string names across documentation files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
docs/essential/best-practice.md (1)

368-371: Commented-out isSignIn examples may have inverted condition

Even though this section is commented out, both isSignIn examples currently return Unauthorized when session.value is truthy rather than when it’s missing. If these snippets are ever re-enabled, you’ll probably want if (!session.value) return status("Unauthorized") for consistency with the other auth examples.

Also applies to: 390-394

docs/tutorial/patterns/error-handling/index.md (1)

48-48: Markdownlint MD010 (hard tabs) hint on this line

markdownlint-cli2 is flagging a hard tab at the start of this line (MD010). If your docs style is moving away from tabs, consider converting this fenced code block’s indentation to spaces or updating the markdownlint config to ignore code fences.

docs/tutorial/getting-started/encapsulation/index.md (1)

45-48: markdownlint MD010 (hard tabs) warnings are non-blocking but worth noting

markdownlint-cli2 flags hard tabs on nearby lines in this fenced code. If you want a clean lint run, consider converting the leading tabs in this block to spaces or relaxing MD010 for code fences; otherwise this can likely be deferred since it doesn’t affect rendered docs.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e5da8b and 7b88bc9.

📒 Files selected for processing (18)
  • docs/eden/treaty/response.md (2 hunks)
  • docs/essential/best-practice.md (3 hunks)
  • docs/essential/life-cycle.md (2 hunks)
  • docs/essential/plugin.md (1 hunks)
  • docs/index.md (3 hunks)
  • docs/integrations/better-auth.md (1 hunks)
  • docs/key-concept.md (1 hunks)
  • docs/patterns/error-handling.md (1 hunks)
  • docs/patterns/extends-context.md (1 hunks)
  • docs/tutorial/getting-started/encapsulation/data.ts (2 hunks)
  • docs/tutorial/getting-started/encapsulation/index.md (6 hunks)
  • docs/tutorial/getting-started/guard/index.md (4 hunks)
  • docs/tutorial/getting-started/life-cycle/index.md (2 hunks)
  • docs/tutorial/getting-started/status-and-headers/index.md (1 hunks)
  • docs/tutorial/getting-started/validation/index.md (1 hunks)
  • docs/tutorial/patterns/error-handling/index.md (1 hunks)
  • docs/tutorial/patterns/extends-context/index.md (1 hunks)
  • docs/tutorial/patterns/macro/index.md (2 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
docs/index.md

115-115: Hard tabs
Column: 1

(MD010, no-hard-tabs)


162-162: Hard tabs
Column: 1

(MD010, no-hard-tabs)


192-192: Hard tabs
Column: 1

(MD010, no-hard-tabs)

docs/essential/plugin.md

118-118: Hard tabs
Column: 1

(MD010, no-hard-tabs)


121-121: Hard tabs
Column: 1

(MD010, no-hard-tabs)


122-122: Hard tabs
Column: 1

(MD010, no-hard-tabs)


125-125: Hard tabs
Column: 1

(MD010, no-hard-tabs)


126-126: Hard tabs
Column: 1

(MD010, no-hard-tabs)

docs/eden/treaty/response.md

149-149: Hard tabs
Column: 1

(MD010, no-hard-tabs)

docs/tutorial/getting-started/guard/index.md

142-142: Hard tabs
Column: 1

(MD010, no-hard-tabs)

docs/tutorial/getting-started/life-cycle/index.md

152-152: Hard tabs
Column: 1

(MD010, no-hard-tabs)

docs/tutorial/patterns/error-handling/index.md

48-48: Hard tabs
Column: 1

(MD010, no-hard-tabs)

docs/tutorial/getting-started/status-and-headers/index.md

52-52: Hard tabs
Column: 1

(MD010, no-hard-tabs)


53-53: Hard tabs
Column: 1

(MD010, no-hard-tabs)

docs/tutorial/getting-started/encapsulation/index.md

47-47: Hard tabs
Column: 1

(MD010, no-hard-tabs)


48-48: Hard tabs
Column: 1

(MD010, no-hard-tabs)

🔇 Additional comments (20)
docs/tutorial/patterns/extends-context/index.md (1)

163-167: Resolve example now uses string status name consistently

The change to status("Unauthorized") here keeps the same control flow while matching the new string-based status style used elsewhere in the docs. Looks good.

docs/essential/best-practice.md (1)

315-323: AuthService macro: string-based Unauthorized status is consistent

Using status("Unauthorized") here preserves the existing behavior (reject when no session cookie) and aligns with the project-wide move away from numeric 401 in docs.

docs/integrations/better-auth.md (1)

187-196: Better Auth macro resolve uses string Unauthorized status correctly

Switching the missing-session check to status("Unauthorized") keeps the same early-return behavior while matching the new documentation convention.

docs/patterns/extends-context.md (1)

317-324: Derive auth example now matches string status convention

Using status("Unauthorized") on missing authorization preserves the early-exit error behavior and keeps this example consistent with other auth-related docs.

docs/tutorial/patterns/macro/index.md (2)

62-69: Auth macro example: Unauthorized string status is appropriate

The macro’s beforeHandle now returns status("Unauthorized") when session.value is missing, which matches the rest of the auth docs without changing behavior.


111-117: Fibonacci macro: explicit “I’m a teapot” reason phrase looks good

Using status("I'm a teapot") here keeps the 418-style example while making the reason phrase explicit and consistent with the string-based status style elsewhere.

docs/tutorial/patterns/error-handling/index.md (1)

44-49: Quoting change in onError handler is safe

Switching to a double-quoted string here preserves the exact message while simplifying escaping; the 418 example remains intact.

docs/tutorial/getting-started/encapsulation/data.ts (1)

7-10: Encapsulation playground code: Unauthorized/Forbidden strings align with tests

Both guards now use status("Unauthorized") and status("Forbidden") instead of numeric codes, while the testcases below still assert on 401 and 403. This matches the new documentation convention without changing the observable behavior of the examples.

Also applies to: 18-21

docs/tutorial/getting-started/encapsulation/index.md (1)

31-37: Encapsulation examples consistently migrated to string status names

All the updated snippets here now use status("Unauthorized") for missing name and status("Forbidden") for underage age, which keeps the same auth/validation behavior while aligning with the project-wide string status convention. The examples remain consistent with the corresponding playground tests and other docs.

Also applies to: 45-51, 71-76, 145-147, 171-188

docs/key-concept.md (1)

22-23: Consistent status name usage in lifecycle examples.

Elysia supports setting status codes using the common name of the status code instead of using a number. The conversion from status(401) to status("Unauthorized") is consistent with this feature and aligns with the PR objectives.

Also applies to: 31-32, 37-37

docs/eden/treaty/response.md (1)

33-33: Consistent string status usage in Eden examples.

The conversion from numeric to string status codes is consistent throughout. However, line 149 contains a hard tab character that violates Markdown formatting standards.

Apply this diff to fix the hard tab on line 149:

- 		if(name === 'Otto') return status("Bad Request")
+ 		if(name === 'Otto') return status("Bad Request")

(The difference is subtle—replace the leading hard tab with spaces to match the file's indent pattern.)

Also applies to: 149-149

docs/tutorial/getting-started/guard/index.md (1)

40-40: Consistent string status usage in guard examples.

The conversion to string-based status names is applied consistently across all guard examples. However, line 142 contains a hard tab that should be replaced with spaces.

Apply this diff to fix the hard tab on line 142:

- 		if(!name) return status("Unauthorized")
+ 		if(!name) return status("Unauthorized")

Also applies to: 51-51, 91-91, 142-142

docs/tutorial/getting-started/validation/index.md (1)

137-137: Status(418) conversion aligns with PR approach.

The conversion to string form status("I'm a teapot", 'Hello Elysia!') is consistent with other examples in the PR. While the PR objectives note that 418 examples were "kept with explanatory notes," the documentation in docs/tutorial/getting-started/status-and-headers/index.md (lines 56-61) confirms both numeric and string forms are equivalent and interchangeable.

docs/index.md (2)

115-115: Hard tabs detected in status examples.

All three instances contain hard tabs that violate Markdown formatting standards and should be replaced with spaces to match the file's indentation.

Apply this diff to fix hard tabs:

- 				if(headers.authorization !== type)
-					return status("Unauthorized")
+ 				if(headers.authorization !== type)
+ 					return status("Unauthorized")

(Repeat for lines 162 and 192.)

Also applies to: 162-162, 192-192


217-217: Inconsistent status code conversion.

Lines 217 and 423 still use status(400, "Oh no") with a numeric code, while most other files have been converted to string equivalents (status("Bad Request", ...)). Per the PR objectives, only status(418) and status(404) are noted as exceptions. Please clarify whether status(400) should also be converted or if these are intentional exceptions.

Also applies to: 423-423

docs/patterns/error-handling.md (1)

311-311: Clear documentation of string status support.

The added explanatory text effectively documents that both numeric and string forms are supported for HTTP status codes. This provides helpful guidance for users choosing between approaches.

docs/essential/life-cycle.md (1)

505-505: Consistent string status usage in lifecycle examples.

The conversion from numeric to string status codes demonstrates the API capability and improves code clarity in auth validation contexts.

Also applies to: 530-530

docs/tutorial/getting-started/status-and-headers/index.md (2)

52-52: Typo fix in status code example.

The correction from "I'm a teapot'" to "I'm a teapot" fixes an unclosed string literal and makes the example valid. However, lines 52-53 contain hard tabs.

Apply this diff to fix hard tabs:

- 	.get('/', ({ status }) => status(418, "I'm a teapot"))
+ 	.get('/', ({ status }) => status(418, "I'm a teapot"))

56-65: Excellent documentation of status code flexibility.

The addition clearly explains that both numeric and string forms are equivalent and supported, with a helpful note that string names provide TypeScript autocompletion. This enhances the learning experience for developers.

docs/tutorial/getting-started/life-cycle/index.md (1)

65-65: Clear explanation of string status syntax.

The documentation addition explaining status("I'm a teapot") alongside the numeric example and doc link is helpful context for users.

Comment on lines 118 to 119
.onBeforeHandle(({ status }) => status("Unauthorized"))
.get('/profile', ({ status }) => status("Unauthorized"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Approve status code conversions; fix hard tab indentation.

The conversions from status(401) to status("Unauthorized") are correct and align with the PR objective. However, the code examples use hard tabs for indentation, which violates the markdown MD010 linting rule. Replace all leading tabs with spaces (typically 2–4 spaces per indent level) for consistency.

Example fix for lines 118–119:

-	.onBeforeHandle(({ status }) => status("Unauthorized"))
-	.get('/profile', ({ status }) => status("Unauthorized"))
+  .onBeforeHandle(({ status }) => status("Unauthorized"))
+  .get('/profile', ({ status }) => status("Unauthorized"))

Apply the same indentation fix (tabs → spaces) to lines 127–128 and line 133.

Also applies to: 127-128, 133-133

🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

118-118: Hard tabs
Column: 1

(MD010, no-hard-tabs)

🤖 Prompt for AI Agents
In docs/essential/plugin.md around lines 118-119 (and also apply to 127-128 and
133), the example code uses hard tab characters for indentation which violates
MD010; replace all leading tabs with spaces (use 2–4 spaces per indent level
consistent with the file) so the lines read with space-based indentation while
leaving the status("Unauthorized") edits intact.

new Elysia()
.onBeforeHandle(({ query: { name }, status }) => {
if(!name) return status(401)
if(!name) return status("Unauthorized")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Replace hard tab with spaces for consistent indentation.

The line uses a hard tab at the start, which violates the markdown linting rule MD010. Replace the tab with spaces to align with markdown formatting standards.

-		if(!name) return status("Unauthorized")
+        if(!name) return status("Unauthorized")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(!name) return status("Unauthorized")
if(!name) return status("Unauthorized")
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

152-152: Hard tabs
Column: 1

(MD010, no-hard-tabs)

🤖 Prompt for AI Agents
In docs/tutorial/getting-started/life-cycle/index.md around line 152, the line
starts with a hard tab which violates MD010; replace the leading tab character
with equivalent spaces (e.g., two or four spaces as used elsewhere in the file)
so the indentation is consistent with the rest of the Markdown document and
passes the linter.

Convert remaining numeric status codes to descriptive strings:
- status(401) → status("Unauthorized") in auth contexts
- status(400) → status("Bad Request") or status("Unauthorized") as appropriate

Files updated:
- docs/index.md (homepage examples)
- docs/integrations/better-auth.md
- docs/tutorial/patterns/extends-context/index.md
- docs/patterns/extends-context.md
- docs/eden/treaty/response.md
@braden-w
Copy link
Contributor Author

braden-w commented Dec 6, 2025

Superseded by #747 (conversions)

@braden-w braden-w closed this Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant