[PR #4738] [CLOSED] refactor: add shared definition files for endpoint #5557

Closed
opened 2026-03-13 12:27:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4738
Author: @himself65
Created: 9/18/2025
Status: Closed

Base: canaryHead: himself65/2025/09/17/def


📝 Commits (2)

  • beb4b51 feat: use def
  • 23fa03d refactor: add shared definition files for endpoint

📊 Changes

36 files changed (+6556 additions, -5145 deletions)

View changed files

📝 docs/components/endpoint.tsx (+0 -2)
📝 docs/components/nav-mobile.tsx (+1 -2)
📝 packages/better-auth/src/api/index.ts (+28 -28)
📝 packages/better-auth/src/api/routes/account.ts (+27 -404)
📝 packages/better-auth/src/api/routes/callback.ts (+5 -13)
📝 packages/better-auth/src/api/routes/email-verification.ts (+150 -332)
📝 packages/better-auth/src/api/routes/error.ts (+5 -29)
📝 packages/better-auth/src/api/routes/ok.ts (+5 -35)
📝 packages/better-auth/src/api/routes/reset-password.ts (+40 -211)
📝 packages/better-auth/src/api/routes/session.ts (+206 -376)
packages/better-auth/src/api/routes/shared.ts (+1197 -0)
📝 packages/better-auth/src/api/routes/sign-in.ts (+8 -328)
📝 packages/better-auth/src/api/routes/sign-out.ts (+5 -32)
📝 packages/better-auth/src/api/routes/sign-up.ts (+162 -309)
📝 packages/better-auth/src/api/routes/update-user.ts (+116 -462)
packages/better-auth/src/better-call/server.ts (+15 -0)
packages/better-auth/src/better-call/shared.ts (+30 -0)
📝 packages/better-auth/src/plugins/admin/admin.ts (+9 -87)
packages/better-auth/src/plugins/admin/admin.ts.backup (+1604 -0)
packages/better-auth/src/plugins/admin/shared.ts (+548 -0)

...and 16 more files

📄 Description

Summary by cubic

Refactored all API and plugin routes to use shared endpoint definitions, enabling type-safe reuse and consistent OpenAPI metadata across client and server. This reduces duplication and standardizes how endpoints are declared and implemented.

  • Refactors

    • Added declareEndpoint (shared) and implEndpoint (server) helpers.
    • Extracted endpoint definitions into shared.ts files for core routes and plugins (admin, api-key, device-authorization, two-factor, username).
    • Updated all routes to implEndpoint(def, handler); centralized schemas and OpenAPI in definitions.
    • Adjusted getEndpoints to call endpoint factories; no path or behavior changes.
    • Minor docs cleanup (removed unused imports).
  • Migration

    • No API changes required for users.
    • For contributors/plugin authors: declare endpoints with declareEndpoint and implement with implEndpoint; many endpoints are now exported as factory functions.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4738 **Author:** [@himself65](https://github.com/himself65) **Created:** 9/18/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `himself65/2025/09/17/def` --- ### 📝 Commits (2) - [`beb4b51`](https://github.com/better-auth/better-auth/commit/beb4b51b1fd65a52d6f289ae32ab5b93bbfb8deb) feat: use def - [`23fa03d`](https://github.com/better-auth/better-auth/commit/23fa03d7c9a4ba1d531690f87aaa2df8699fe4f0) refactor: add shared definition files for endpoint ### 📊 Changes **36 files changed** (+6556 additions, -5145 deletions) <details> <summary>View changed files</summary> 📝 `docs/components/endpoint.tsx` (+0 -2) 📝 `docs/components/nav-mobile.tsx` (+1 -2) 📝 `packages/better-auth/src/api/index.ts` (+28 -28) 📝 `packages/better-auth/src/api/routes/account.ts` (+27 -404) 📝 `packages/better-auth/src/api/routes/callback.ts` (+5 -13) 📝 `packages/better-auth/src/api/routes/email-verification.ts` (+150 -332) 📝 `packages/better-auth/src/api/routes/error.ts` (+5 -29) 📝 `packages/better-auth/src/api/routes/ok.ts` (+5 -35) 📝 `packages/better-auth/src/api/routes/reset-password.ts` (+40 -211) 📝 `packages/better-auth/src/api/routes/session.ts` (+206 -376) ➕ `packages/better-auth/src/api/routes/shared.ts` (+1197 -0) 📝 `packages/better-auth/src/api/routes/sign-in.ts` (+8 -328) 📝 `packages/better-auth/src/api/routes/sign-out.ts` (+5 -32) 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+162 -309) 📝 `packages/better-auth/src/api/routes/update-user.ts` (+116 -462) ➕ `packages/better-auth/src/better-call/server.ts` (+15 -0) ➕ `packages/better-auth/src/better-call/shared.ts` (+30 -0) 📝 `packages/better-auth/src/plugins/admin/admin.ts` (+9 -87) ➕ `packages/better-auth/src/plugins/admin/admin.ts.backup` (+1604 -0) ➕ `packages/better-auth/src/plugins/admin/shared.ts` (+548 -0) _...and 16 more files_ </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Refactored all API and plugin routes to use shared endpoint definitions, enabling type-safe reuse and consistent OpenAPI metadata across client and server. This reduces duplication and standardizes how endpoints are declared and implemented. - **Refactors** - Added declareEndpoint (shared) and implEndpoint (server) helpers. - Extracted endpoint definitions into shared.ts files for core routes and plugins (admin, api-key, device-authorization, two-factor, username). - Updated all routes to implEndpoint(def, handler); centralized schemas and OpenAPI in definitions. - Adjusted getEndpoints to call endpoint factories; no path or behavior changes. - Minor docs cleanup (removed unused imports). - **Migration** - No API changes required for users. - For contributors/plugin authors: declare endpoints with declareEndpoint and implement with implEndpoint; many endpoints are now exported as factory functions. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:27:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#5557