Skip to content

Add .alias() to serve one handler under multiple route paths - #29

Merged
nvie merged 3 commits into
mainfrom
aliases
Jul 2, 2026
Merged

nvie merged 3 commits into
mainfrom
aliases

Conversation

@nvie

@nvie nvie commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@nvie nvie self-assigned this Jul 2, 2026
@vercel

vercel Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zenrouter Ready Ready Preview, Comment Jul 2, 2026 9:54am

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces first-class route aliasing to ZenRouter, allowing a single already-registered route handler (including its auth + body validation) to be exposed under additional route patterns without duplicating implementation.

Changes:

  • Add ZenRouter.alias(aliasPattern, targetPattern) to register a second route that reuses an existing route’s handler/auth/body schema.
  • Add extractParamNames() to support alias validation (same HTTP method + same declared param names).
  • Add tests, documentation, and changelog entry for the new .alias() API.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/Router.test.ts Adds coverage for .alias() behavior (handler reuse, schema reuse, and config errors).
src/Router.ts Implements ZenRouter.alias() with validation and reuses existing route tuple components.
src/lib/matchers.ts Adds extractParamNames() helper to derive declared param names from patterns.
docs/content/docs/routes.mdx Documents .alias() usage and constraints.
CHANGELOG.md Notes the new .alias() feature under Unreleased.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/content/docs/routes.mdx Resolved
Comment thread test/Router.test.ts Resolved
@nvie
nvie merged commit eddc392 into main Jul 2, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — 33ca5dda Deployed Jul 2, 2026 by vercel[bot]
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