Code Monkey home page Code Monkey logo

Comments (5)

katsanva avatar katsanva commented on July 18, 2024 3

Hey, @nmaro

Its all about to decouple oooh from express and HTTP protocol only.

The idea is to make same API to HTTP one, like POST /local/register -> ooth.local.register() and so on. Going this way to create an instance you need only to define what strategies should ooth use and what backend for users to use.

It may be the best way to re-use passport strategies without actual passport.js usage.

The express usage may persist in some ooth-express package, which will only call ooth.local.register() and so on under the hood.

from ooth.

aaronmgdr avatar aaronmgdr commented on July 18, 2024

I like this

from ooth.

nickredmark avatar nickredmark commented on July 18, 2024

Good idea.

from ooth.

nickredmark avatar nickredmark commented on July 18, 2024

Hey @katsanva since I believe this will generate a major release I think we need to discuss the details a bit more.

Ooth is coupled to express, because it is coupled to passport.js which injects the user in the request and session. I think I need a better idea of where you want to make the decoupling cut. Could give some examples of

  • methods that you would like to call on such a programmatic API (and what they would do).
  • What you would give to the ooth constructor instead of an express app.

A note: the express app provided to ooth is used to

  • register a few global middlewares (cookieParser, bodyParser, passport and expressWs)
  • register express.Router to which all routes are registered (methods called are all, get, ws, post).

from ooth.

nickredmark avatar nickredmark commented on July 18, 2024

Now every method registered with

ooth.registerMethod can be called with ooth.callMethod

For example with ooth-local it is now possible to run

ooth.on('register', ({_id, email, verificationToken}) => ...))

await ooth.callMethod('local', 'register', { email, password })

If this doesn't satisfy all your use cases just let me know, I'll close this for now.

from ooth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.