-
Notifications
You must be signed in to change notification settings - Fork 390
chore(backend): Add helper type for auth helpers without request parameters #6910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 5d93a54 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
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.
|
WalkthroughType-level refactors expose Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (7)**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
packages/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
packages/**/*.{ts,tsx,d.ts}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{js,ts,tsx,jsx}📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Files:
**/__tests__/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
Files:
🧬 Code graph analysis (1)packages/backend/src/tokens/__tests__/getAuth.test-d.ts (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
🔇 Additional comments (5)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/express/src/getAuth.ts (1)
11-15
: JSDoc still references the old options type.We now accept
AuthOptions
, but the doc block still points toGetAuthOptions
. Please update the annotation so the public docs stay accurate.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (12)
.changeset/real-trainers-knock.md
(1 hunks)packages/astro/src/server/clerk-middleware.ts
(3 hunks)packages/astro/src/server/types.ts
(2 hunks)packages/backend/src/internal.ts
(1 hunks)packages/backend/src/tokens/__tests__/getAuth.test-d.ts
(1 hunks)packages/backend/src/tokens/types.ts
(2 hunks)packages/express/src/getAuth.ts
(1 hunks)packages/fastify/src/getAuth.ts
(1 hunks)packages/nextjs/src/app-router/server/auth.ts
(5 hunks)packages/nuxt/src/runtime/server/__tests__/auth.test-d.ts
(1 hunks)packages/nuxt/src/runtime/server/types.ts
(1 hunks)packages/tanstack-react-start/src/server/getAuth.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/nuxt/src/runtime/server/__tests__/auth.test-d.ts
packages/backend/src/internal.ts
packages/nuxt/src/runtime/server/types.ts
packages/fastify/src/getAuth.ts
packages/express/src/getAuth.ts
packages/astro/src/server/types.ts
packages/backend/src/tokens/__tests__/getAuth.test-d.ts
packages/backend/src/tokens/types.ts
packages/tanstack-react-start/src/server/getAuth.ts
packages/nextjs/src/app-router/server/auth.ts
packages/astro/src/server/clerk-middleware.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/nuxt/src/runtime/server/__tests__/auth.test-d.ts
packages/backend/src/internal.ts
packages/nuxt/src/runtime/server/types.ts
packages/fastify/src/getAuth.ts
packages/express/src/getAuth.ts
packages/astro/src/server/types.ts
packages/backend/src/tokens/__tests__/getAuth.test-d.ts
packages/backend/src/tokens/types.ts
packages/tanstack-react-start/src/server/getAuth.ts
packages/nextjs/src/app-router/server/auth.ts
packages/astro/src/server/clerk-middleware.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/nuxt/src/runtime/server/__tests__/auth.test-d.ts
packages/backend/src/internal.ts
packages/nuxt/src/runtime/server/types.ts
packages/fastify/src/getAuth.ts
packages/express/src/getAuth.ts
packages/astro/src/server/types.ts
packages/backend/src/tokens/__tests__/getAuth.test-d.ts
packages/backend/src/tokens/types.ts
packages/tanstack-react-start/src/server/getAuth.ts
packages/nextjs/src/app-router/server/auth.ts
packages/astro/src/server/clerk-middleware.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/nuxt/src/runtime/server/__tests__/auth.test-d.ts
packages/backend/src/internal.ts
packages/nuxt/src/runtime/server/types.ts
packages/fastify/src/getAuth.ts
packages/express/src/getAuth.ts
packages/astro/src/server/types.ts
packages/backend/src/tokens/__tests__/getAuth.test-d.ts
packages/backend/src/tokens/types.ts
packages/tanstack-react-start/src/server/getAuth.ts
packages/nextjs/src/app-router/server/auth.ts
packages/astro/src/server/clerk-middleware.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/nuxt/src/runtime/server/__tests__/auth.test-d.ts
packages/backend/src/internal.ts
packages/nuxt/src/runtime/server/types.ts
packages/fastify/src/getAuth.ts
packages/express/src/getAuth.ts
packages/astro/src/server/types.ts
packages/backend/src/tokens/__tests__/getAuth.test-d.ts
packages/backend/src/tokens/types.ts
packages/tanstack-react-start/src/server/getAuth.ts
packages/nextjs/src/app-router/server/auth.ts
packages/astro/src/server/clerk-middleware.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/nuxt/src/runtime/server/__tests__/auth.test-d.ts
packages/backend/src/internal.ts
packages/nuxt/src/runtime/server/types.ts
packages/fastify/src/getAuth.ts
packages/express/src/getAuth.ts
packages/astro/src/server/types.ts
packages/backend/src/tokens/__tests__/getAuth.test-d.ts
packages/backend/src/tokens/types.ts
packages/tanstack-react-start/src/server/getAuth.ts
packages/nextjs/src/app-router/server/auth.ts
packages/astro/src/server/clerk-middleware.ts
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}
: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/nuxt/src/runtime/server/__tests__/auth.test-d.ts
packages/backend/src/tokens/__tests__/getAuth.test-d.ts
.changeset/**
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/real-trainers-knock.md
🧬 Code graph analysis (10)
packages/nuxt/src/runtime/server/__tests__/auth.test-d.ts (3)
packages/nuxt/src/runtime/server/types.ts (1)
AuthFn
(9-9)packages/backend/src/tokens/types.ts (2)
SessionAuthObject
(185-185)MachineAuthObject
(186-188)packages/backend/src/tokens/authObjects.ts (2)
InvalidTokenAuthObject
(150-156)AuthObject
(161-166)
packages/nuxt/src/runtime/server/types.ts (3)
packages/backend/src/internal.ts (3)
AuthOptions
(16-16)AuthenticateRequestOptions
(11-11)GetAuthFnNoRequest
(17-17)packages/backend/src/tokens/types.ts (3)
AuthOptions
(190-190)AuthenticateRequestOptions
(19-75)GetAuthFnNoRequest
(244-284)packages/types/src/session.ts (1)
PendingSessionOptions
(34-40)
packages/fastify/src/getAuth.ts (4)
packages/express/src/getAuth.ts (1)
getAuth
(15-23)packages/backend/src/internal.ts (2)
GetAuthFn
(15-15)AuthOptions
(16-16)packages/backend/src/tokens/types.ts (2)
GetAuthFn
(199-236)AuthOptions
(190-190)packages/nuxt/src/runtime/server/types.ts (1)
AuthOptions
(4-4)
packages/express/src/getAuth.ts (2)
packages/fastify/src/getAuth.ts (1)
getAuth
(7-15)packages/backend/src/tokens/types.ts (2)
GetAuthFn
(199-236)AuthOptions
(190-190)
packages/astro/src/server/types.ts (1)
packages/backend/src/tokens/types.ts (2)
SessionAuthObject
(185-185)GetAuthFnNoRequest
(244-284)
packages/backend/src/tokens/__tests__/getAuth.test-d.ts (4)
packages/backend/src/internal.ts (3)
GetAuthFn
(15-15)RedirectFun
(3-3)GetAuthFnNoRequest
(17-17)packages/backend/src/tokens/types.ts (4)
GetAuthFn
(199-236)SessionAuthObject
(185-185)MachineAuthObject
(186-188)GetAuthFnNoRequest
(244-284)packages/backend/src/tokens/authObjects.ts (2)
InvalidTokenAuthObject
(150-156)AuthObject
(161-166)packages/nextjs/src/app-router/server/auth.ts (2)
auth
(71-141)SessionAuthWithRedirect
(20-40)
packages/backend/src/tokens/types.ts (4)
packages/nuxt/src/runtime/server/types.ts (1)
AuthOptions
(4-4)packages/types/src/session.ts (1)
PendingSessionOptions
(34-40)packages/backend/src/tokens/tokenTypes.ts (3)
TokenType
(1-6)TokenType
(11-11)SessionTokenType
(16-16)packages/backend/src/tokens/authObjects.ts (2)
InvalidTokenAuthObject
(150-156)AuthObject
(161-166)
packages/tanstack-react-start/src/server/getAuth.ts (3)
packages/express/src/getAuth.ts (1)
getAuth
(15-23)packages/fastify/src/getAuth.ts (1)
getAuth
(7-15)packages/backend/src/tokens/types.ts (2)
GetAuthFn
(199-236)AuthOptions
(190-190)
packages/nextjs/src/app-router/server/auth.ts (2)
packages/backend/src/tokens/types.ts (2)
SessionAuthObject
(185-185)GetAuthFnNoRequest
(244-284)packages/backend/src/createRedirect.ts (1)
RedirectFun
(67-67)
packages/astro/src/server/clerk-middleware.ts (1)
packages/astro/src/server/types.ts (1)
SessionAuthObjectWithRedirect
(21-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
Description
This PR introduces
GetAuthFnNoRequest
forauth()/getAuth()
helpers that don't require a request parameter (Next.js, Astro, Nuxt) and consolidates auth function type definitions across all Clerk SDKs. This eliminates type duplication and ensures consistency between frameworks with and without request parameters.This is a purely internal refactoring that maintains the same public API.
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit