-
Notifications
You must be signed in to change notification settings - Fork 402
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
Conversation
🦋 Changeset detectedLatest commit: 6471cc3 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)
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.tspackages/backend/src/internal.tspackages/nuxt/src/runtime/server/types.tspackages/fastify/src/getAuth.tspackages/express/src/getAuth.tspackages/astro/src/server/types.tspackages/backend/src/tokens/__tests__/getAuth.test-d.tspackages/backend/src/tokens/types.tspackages/tanstack-react-start/src/server/getAuth.tspackages/nextjs/src/app-router/server/auth.tspackages/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.tspackages/backend/src/internal.tspackages/nuxt/src/runtime/server/types.tspackages/fastify/src/getAuth.tspackages/express/src/getAuth.tspackages/astro/src/server/types.tspackages/backend/src/tokens/__tests__/getAuth.test-d.tspackages/backend/src/tokens/types.tspackages/tanstack-react-start/src/server/getAuth.tspackages/nextjs/src/app-router/server/auth.tspackages/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.tspackages/backend/src/internal.tspackages/nuxt/src/runtime/server/types.tspackages/fastify/src/getAuth.tspackages/express/src/getAuth.tspackages/astro/src/server/types.tspackages/backend/src/tokens/__tests__/getAuth.test-d.tspackages/backend/src/tokens/types.tspackages/tanstack-react-start/src/server/getAuth.tspackages/nextjs/src/app-router/server/auth.tspackages/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.tspackages/backend/src/internal.tspackages/nuxt/src/runtime/server/types.tspackages/fastify/src/getAuth.tspackages/express/src/getAuth.tspackages/astro/src/server/types.tspackages/backend/src/tokens/__tests__/getAuth.test-d.tspackages/backend/src/tokens/types.tspackages/tanstack-react-start/src/server/getAuth.tspackages/nextjs/src/app-router/server/auth.tspackages/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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor 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 assertionsfor literal types:as const
Usesatisfiesoperator 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 ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor 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.tspackages/backend/src/internal.tspackages/nuxt/src/runtime/server/types.tspackages/fastify/src/getAuth.tspackages/express/src/getAuth.tspackages/astro/src/server/types.tspackages/backend/src/tokens/__tests__/getAuth.test-d.tspackages/backend/src/tokens/types.tspackages/tanstack-react-start/src/server/getAuth.tspackages/nextjs/src/app-router/server/auth.tspackages/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.tspackages/backend/src/internal.tspackages/nuxt/src/runtime/server/types.tspackages/fastify/src/getAuth.tspackages/express/src/getAuth.tspackages/astro/src/server/types.tspackages/backend/src/tokens/__tests__/getAuth.test-d.tspackages/backend/src/tokens/types.tspackages/tanstack-react-start/src/server/getAuth.tspackages/nextjs/src/app-router/server/auth.tspackages/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.tspackages/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: |
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)
.changeset/real-trainers-knock.md (1)
11-11: Clarify the changeset note (name the type and state type-only).Suggest explicitly naming the new helper type and noting no public API change.
-Added internal helper type for `auth` and `getAuth()` functions that don't require a request or context parameter +Type-only: Introduce `GetAuthFnNoRequest` for `auth()`/`getAuth()` helpers that don't take a request/context (Next.js, Astro, Nuxt). +Internal refactor; no public API changes.
📜 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 (1)
.changeset/real-trainers-knock.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/**
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/real-trainers-knock.md
⏰ 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). (8)
- GitHub Check: pr-title-lint
- GitHub Check: check-major-bump
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
.changeset/real-trainers-knock.md (1)
2-8: Patch bumps look right; double-check coverage.List matches the frameworks touched. Please confirm no other impacted workspace packages need a bump and that dependents (if any) will be auto-bumped by Changesets.
Description
This PR introduces a internal
GetAuthFnNoRequesttype forauth()/getAuth()helpers that don't require a request parameter (Next.js, Astro, Nuxt, TanStack Start) and consolidates auth function type definitions across all Clerk SDKs. This eliminates type duplication and ensures consistency between SDKs without request/context parameters.For context, we also have a
GetAuthFnshared helper type, but it is for SDKs like Express, Fastify and React Router where a request/context param is required:This is a purely internal refactoring that maintains the same public API.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit