Skip to content

Conversation

@balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Sep 29, 2021

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 and res 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 #1535

Thanks 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:

  • signin
  • signout
  • error
  • verify-request
  • new-user

routes:

  • session
  • providers
  • csrf
  • _log
  • signin
  • signout
  • callback

Also, related: #2612, #2433

@github-actions github-actions bot added core Refers to `@auth/core` pages labels Sep 29, 2021
@balazsorban44 balazsorban44 changed the title refactor: decouple Next.js from core (WIP) refactor: decouple Next.js from core Sep 29, 2021
@balazsorban44 balazsorban44 temporarily deployed to Preview September 29, 2021 12:41 Inactive
@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2021

Codecov Report

Merging #2857 (f71bfe0) into beta (58a98b6) will decrease coverage by 0.69%.
The diff coverage is 1.90%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/client/_utils.ts 81.25% <ø> (ø)
src/core/errors.ts 0.00% <ø> (ø)
src/core/index.ts 0.00% <0.00%> (ø)
src/core/init.ts 0.00% <0.00%> (ø)
src/core/lib/callback-handler.ts 0.00% <0.00%> (ø)
src/core/lib/callback-url.ts 0.00% <0.00%> (ø)
src/core/lib/cookie.ts 0.00% <ø> (ø)
src/core/lib/csrf-token.ts 0.00% <0.00%> (ø)
src/core/lib/default-callbacks.ts 0.00% <ø> (ø)
src/core/lib/email/signin.ts 0.00% <0.00%> (ø)
... and 28 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58a98b6...f71bfe0. Read the comment docs.

@balazsorban44
Copy link
Member Author

Done, but I will do some cleanup and testing.

@github-actions
Copy link

github-actions bot commented Sep 29, 2021

🎉 Experimental release published on npm!

@balazsorban44 balazsorban44 temporarily deployed to Preview September 29, 2021 12:49 Inactive
@balazsorban44 balazsorban44 temporarily deployed to Preview October 1, 2021 17:01 Inactive
@balazsorban44 balazsorban44 temporarily deployed to Preview October 2, 2021 22:55 Inactive
@balazsorban44 balazsorban44 temporarily deployed to Preview October 3, 2021 11:31 Inactive
@github-actions github-actions bot added the client Client related code label Oct 13, 2021
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
Copy link
Member

@ndom91 ndom91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@balazsorban44 balazsorban44 merged commit eb33c9d into beta Oct 27, 2021
@balazsorban44 balazsorban44 deleted the feat/decouple branch October 27, 2021 14:11
@balazsorban44 balazsorban44 mentioned this pull request Oct 28, 2021
3 tasks
mnphpexpert added a commit to mnphpexpert/next-auth that referenced this pull request Sep 2, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Client related code core Refers to `@auth/core` pages providers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants