chore(astro): Deprecate createRouteMatcher#8981
Conversation
🦋 Changeset detectedLatest commit: 2534134 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthrough
ChangesAstro route matcher deprecation
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
API Changes Report
Summary
No API Changes DetectedAll packages have stable APIs with no detected changes. Report generated by Break Check Last ran on |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/astro/src/server/route-matcher.ts`:
- Around line 35-43: The exported createRouteMatcher API currently relies on
inferred return type, which makes the public contract less explicit. Add an
explicit return type to createRouteMatcher and ensure it matches the function
returned by createPathMatcher, keeping the exported matcher signature clear and
stable for consumers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Repository UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 67533d06-221e-428e-9e17-5a6b0a32c6cf
📒 Files selected for processing (2)
.changeset/soft-astro-routes.mdpackages/astro/src/server/route-matcher.ts
| export const createRouteMatcher = (routes: RouteMatcherParam) => { | ||
| deprecated( | ||
| 'createRouteMatcher', | ||
| 'Use resource-based auth checks instead. Move auth checks into each Astro page, API route, or server-side handler that accesses protected data. Middleware-based auth checks rely on path matching, which can diverge from how Astro routes requests and leave protected resources reachable.', | ||
| ); | ||
|
|
||
| const matcher = createPathMatcher(routes); | ||
| return (req: Request) => matcher(new URL(req.url).pathname); | ||
| }; |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add an explicit return type for the exported API.
createRouteMatcher is exported but currently relies on inference. Please add an explicit function return type on Line 35 to keep the public surface unambiguous.
Suggested change
-export const createRouteMatcher = (routes: RouteMatcherParam) => {
+export const createRouteMatcher = (
+ routes: RouteMatcherParam,
+): ((req: Request) => boolean) => {📝 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.
| export const createRouteMatcher = (routes: RouteMatcherParam) => { | |
| deprecated( | |
| 'createRouteMatcher', | |
| 'Use resource-based auth checks instead. Move auth checks into each Astro page, API route, or server-side handler that accesses protected data. Middleware-based auth checks rely on path matching, which can diverge from how Astro routes requests and leave protected resources reachable.', | |
| ); | |
| const matcher = createPathMatcher(routes); | |
| return (req: Request) => matcher(new URL(req.url).pathname); | |
| }; | |
| export const createRouteMatcher = ( | |
| routes: RouteMatcherParam, | |
| ): ((req: Request) => boolean) => { | |
| deprecated( | |
| 'createRouteMatcher', | |
| 'Use resource-based auth checks instead. Move auth checks into each Astro page, API route, or server-side handler that accesses protected data. Middleware-based auth checks rely on path matching, which can diverge from how Astro routes requests and leave protected resources reachable.', | |
| ); | |
| const matcher = createPathMatcher(routes); | |
| return (req: Request) => matcher(new URL(req.url).pathname); | |
| }; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/astro/src/server/route-matcher.ts` around lines 35 - 43, The
exported createRouteMatcher API currently relies on inferred return type, which
makes the public contract less explicit. Add an explicit return type to
createRouteMatcher and ensure it matches the function returned by
createPathMatcher, keeping the exported matcher signature clear and stable for
consumers.
Sources: Coding guidelines, Learnings
Ephem
left a comment
There was a problem hiding this comment.
Looks great to me, very solid and readable messages with good guidance!
Description
Deprecates
createRouteMatcher()in@clerk/astro.The replacement recommendation is to use resource-based auth checks: move auth checks into each Astro page, API route, or server-side handler that accesses protected data.
This follows the broader direction of moving away from middleware route matching for auth protection.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
createRouteMatcher()is now clearly marked as deprecated, with a warning shown when it’s used.401 Unauthorizedwhen a user is not signed in.