Skip to content

docs: replace deprecated v1 createRouter/router.use with v2#1337

Merged
pi0 merged 1 commit intomainfrom
docs/fix-v1-patterns
Mar 15, 2026
Merged

docs: replace deprecated v1 createRouter/router.use with v2#1337
pi0 merged 1 commit intomainfrom
docs/fix-v1-patterns

Conversation

@productdevbook
Copy link
Member

@productdevbook productdevbook commented Mar 15, 2026

Summary

Replace deprecated v1 createRouter() + router.use() patterns with v2 app.all() in docs and JSDoc:

  • docs/utils/security.md — handleCors example
  • docs/examples/validate-data.md — 3 validation examples
  • src/utils/cors.ts — handleCors JSDoc example

createRouter is a v1 API aliased in _deprecated.ts. In v2, routes are registered directly on the H3 instance.

Test plan

  • Documentation + JSDoc only, no runtime changes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated code examples and documentation guides to reflect current implementation patterns and best practices.

- security.md: createRouter() + router.use() → app.all()
- validate-data.md: router.use() → app.all() (3 occurrences)
- cors.ts JSDoc: createRouter() + router.use() → app.all()

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@productdevbook productdevbook requested a review from pi0 as a code owner March 15, 2026 07:26
@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

📝 Walkthrough

Walkthrough

This PR updates route registration patterns across documentation and code examples, replacing router.use() calls with app.all() for specified paths. The changes affect both markdown documentation files and JSDoc comments, with no functional behavior modifications to the application logic.

Changes

Cohort / File(s) Summary
Route Registration Pattern Updates
docs/2.utils/4.security.md, docs/4.examples/validate-data.md, src/utils/cors.ts
Replaces router.use() with app.all() for route registration across documentation examples and JSDoc comments. Updates pattern from router-based middleware to app-level route handlers while maintaining identical observable behavior.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested reviewers

  • pi0

Poem

🐰 A hop, a skip, the routes align,
From routers old to apps so fine,
With app.all() the paths now run,
All methods welcome—oh what fun!
The bunny's refactor, simple and clean! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: replacing deprecated v1 createRouter/router.use patterns with v2 patterns (app.all) in documentation and JSDoc examples.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/fix-v1-patterns
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/h3@1337

commit: b804627

Copy link

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/4.examples/validate-data.md`:
- Around line 49-51: Update the explanatory comment above the route that
currently reads “You must use a router to use params” to avoid v1 terminology
confusion; instead, clarify that route parameters are supported by app methods
(e.g., app.all) and routers alike and reference the example path
"/content/:topic/:uuid" so readers know params work with
app.all("/content/:topic/:uuid", ...) as well as with express.Router instances.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b239f293-c653-493a-807e-094e44f61ef9

📥 Commits

Reviewing files that changed from the base of the PR and between 10bc7ce and b804627.

📒 Files selected for processing (3)
  • docs/2.utils/4.security.md
  • docs/4.examples/validate-data.md
  • src/utils/cors.ts

Comment on lines +49 to 51
app.all(
// You must use a router to use params
"/content/:topic/:uuid",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Update outdated wording about router usage in params example.

Line 50 says “You must use a router to use params”, but the snippet now demonstrates app.all(...). Please reword this note to avoid v1 terminology confusion.

Suggested doc tweak
-app.all(
-  // You must use a router to use params
+app.all(
+  // Use a path pattern with params
   "/content/:topic/:uuid",
📝 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
app.all(
// You must use a router to use params
"/content/:topic/:uuid",
app.all(
// Use a path pattern with params
"/content/:topic/:uuid",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/4.examples/validate-data.md` around lines 49 - 51, Update the
explanatory comment above the route that currently reads “You must use a router
to use params” to avoid v1 terminology confusion; instead, clarify that route
parameters are supported by app methods (e.g., app.all) and routers alike and
reference the example path "/content/:topic/:uuid" so readers know params work
with app.all("/content/:topic/:uuid", ...) as well as with express.Router
instances.

@pi0 pi0 changed the title docs: replace deprecated v1 createRouter/router.use with v2 patterns docs: replace deprecated v1 createRouter/router.use with v2 Mar 15, 2026
@pi0 pi0 merged commit 972184d into main Mar 15, 2026
8 checks passed
@pi0 pi0 deleted the docs/fix-v1-patterns branch March 15, 2026 10:04
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.

2 participants