-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
refactor: decouple Next.js from core #2857
Conversation
Codecov Report
@@ Coverage Diff @@
## beta #2857 +/- ##
==========================================
- Coverage 14.07% 13.38% -0.70%
==========================================
Files 85 86 +1
Lines 1357 1390 +33
Branches 392 400 +8
==========================================
- Hits 191 186 -5
- Misses 1107 1197 +90
+ Partials 59 7 -52
Continue to review full report at Codecov.
|
Done, but I will do some cleanup and testing. |
🎉 Experimental release published on npm! npm i next-auth@0.0.0-pr.2857.5130374a yarn add next-auth@0.0.0-pr.2857.5130374a |
Conflicts: src/core/lib/oauth/authorization-url.ts src/core/pages/error.tsx src/core/pages/signin.tsx src/core/pages/signout.tsx src/core/pages/verify-request.tsx src/server/lib/oauth/authorization-url.js src/server/pages/error.tsx src/server/pages/signin.tsx src/server/pages/signout.tsx src/server/pages/verify-request.tsx
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.
LGTM 👍
* refactor: decouple Next.js from core (WIP) * refactor: use `base` instead of `baseUrl`+`basePath` * fix: signout route * refactor(ts): convert files to TS * fix: imports * refactor: convert callback route * fix: add `next` files to package * chore(dev): alias npm email * refactor: do not merge req with user options * refactor: rename userOptions to options * refactor: use native `URL` in `parseUrl` * refactor: move Next.js specific code to `next` module * refactor(ts): return `OutgoingResponse` on all routes * fix: change `base` to `url` * feat: introduce `getServerSession` * refactor: move main logic to `handler` file * chore(dev): showcase `getServerSession` * feat: extract `sessionToken` from Authorization header * fix: pass headers to getServerSession * refactor: rename `server` to `core` * refactor: re-export `next-auth/next` in `next-auth` * fix: add `core` to npm package * fix: re-export default method * feat: return `body`+`header` instead of `json`,`text` * feat: pass `NEXTAUTH_URL` as a variable to core * refactor: simplify Next.js wrapper * feat: export `client/_utils` * fix(ts): suppress TS errors
Using a similar API to SvelteKit endpoints (https://kit.svelte.dev/docs#routing-endpoints), we can create pure functions without the need of mutating
req
andres
deeply nested in the core of NextAuth.js.This will open up new possibilities like expanding to other frameworks #2294 and implement methods like
getServerSession
#1535Thanks to the TypeScript refactoring of the core I did earlier in #2552, I have so much confidence doing this, it might actually make it into v4 after all...
pages:
routes:
Also, related: #2612, #2433