Closed hillac closed 10 months ago
Thanks for putting this issue together @hillac! As the creator of the demo repository I would also love to see official support and community efforts on the logic required to translate between Web Request/Response APIs and Express' APIs. I have brought it to a working state in my repository, but more hands and eyes on it would improve its quality and make it more useful to the community.
I think being added as a frameworks-express
(e.g exposing a router that could be plugged into Express) could be the best path towards this, but also docs/a guide, or even a stand-alone library could also achieve similar! I would appreciate thoughts from maintainers and the community on this!
Thanks!
As far as I can tell, all we need is a wrapper around @auth/core
that transforms Request
-> Response
to Node.js' req
and res
. The linked demo has that already, nice work!
If someone opens a PR, we could discuss further there.
As for documentation, we prefer JSDoc, that we can then use to auto-generate our docs site.
See https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/index.ts for an example. Rendered here: https://authjs.dev/reference/core
Looking forward to @auth/express
Thank you for the comments and guidance @balazsorban44 π! Youβre right, the translation wrapper should be all that is needed, and is taken care of in the demo!
@hillac, what do you say to pairing together to put together a PR for review and discussion?
We can follow closely, the standard setup in frameworks-x directories, and follow the approach from the demo.
Also @balazsorban44, there were some more specific pieces such as having a body parser middleware in the app to make the translation fully possible. I will call these out in the JSDoc and PR to make sure weβd be taking the right approach there.
Thanks to you both again π!
Yep sounds good.
cant' tell you how much im looking forward to drop kicking passportjs in my nestjs application in favor of this....
Thank you for working on this! β€οΈ Any progress so far?π€
Thank you for working on this! β€οΈ Any progress so far?π€
It's pretty much done https://github.com/nextauthjs/next-auth/pull/8354. But no word from the maintainers on it since August so I'm not sure when it will happen. You can just use the index and http-api-adapters files directly in your project for now, it's only a bit over 100 lines, so you can easily audit it.
Description π
I've seen several issues / posts related to support for express.js and want to use it myself. I would like to propose adding express as an officially supported framework. Given the intention to support more frameworks, I think it would be worthwhile bringing direct support for Auth.js to the most popular back end javascript framework.
Here is an example implementation: rexfordessilfie/authjs-express-demo, which implements a translation layer for the web standard api request/response to express requests/responses, and express middleware for JWT authentication. So support seems quite straightforward.
I'd be willing help with this / add documentation for using express. If this feature is not accepted, I'm also happy to just write docs for using it like in authjs-express-demo if anyone else considers that worthwhile.
Some links to related issues:
https://github.com/nextauthjs/next-auth/issues/8158
https://github.com/nextauthjs/next-auth/issues/7647
https://github.com/nextauthjs/next-auth/issues/6417
For older versions:
On reddit:
How to reproduce βοΈ
https://github.com/rexfordessilfie/authjs-express-demo
Contributing ππ½
Yes, I am willing to help implement this feature in a PR