Repository navigation
Conversation
auth.ts had grown to 1670 lines mixing the BetterAuth options, five plugins with their helpers, three hook families and the event bridge. It now lives in apps/api/src/auth/: index.ts keeps the options, the plugin array in its load-bearing order and the singleton, and each plugin, hook and shared helper gets its own file. auth-queries.ts and auth-session-payload.ts move into the folder as queries.ts and session-payload.ts. The move is pure relocation: every block keeps its text and its di access, the plugin and hook order is unchanged, and the before hook reads the session through an injected reader instead of importing the singleton. Guard tests pinned the after hook, the organization hooks, the plugin order and the before hook wiring on the unmodified code first. Docs, skills and comments that cited the old paths follow.
Plugin files imported each other and the hooks imported plugin files for the SSO entitlement gate, the seat cap and the SCIM user events. Those helpers now live in auth/entitlements.ts, auth/seats.ts and auth/scim-events.ts, so a plugin file never imports another plugin file and a hook never imports a plugin file. The first-verification policy acceptance joins email.ts, the redundant below-cap seat cases fold into one, and the docs and path comments point at the new files.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #178
apps/api/src/auth.ts(1670 lines) becomesapps/api/src/auth/:index.tskeeps the options, the plugin array and theauthsingletonstripe,organization,sso,scim,clear-expired-ban,security-signals) and per hook (before,after,database), plus six shared helpersauth-queries.tsandauth-session-payload.tsmove toauth/queries.tsandauth/session-payload.ts, importers andmock.modulepaths followdiaccess, same plugin and hook order; the before hook reads the session through an injected reader instead of importingauthapi-shapeunchanged, real-database checks that load auth green, docs and skills point at the new pathsAuthDeps,createAuth) stays for the follow-up PR