Git Product home page Git Product logo

Comments (6)

simov avatar simov commented on April 27, 2024

What you are looking at is in fact a middleware. Can you give me a short code example showing what are the other possible options to define a middleware?

from grant.

bitinn avatar bitinn commented on April 27, 2024

I mean avoid having to do mount.

With mount you are essentially wrapping oauth into it's own koa app, and since it's a koa app, it comes with koa module dependencies, and creating problems for project that use a different session solution, or even just a different version of the same module.

It would be more flexible to transform koa this context alone, and leave router and session management independent (abstract them so that developers can write adapters to make other modules to work with grant).

from grant.

simov avatar simov commented on April 27, 2024

@bitinn check out this commit 9204806

The Koa middleware no longer require specific session store to use, but it is required to use one and set it before mounting grant.

I tested it with a bunch of session store modules here https://github.com/simov/grant/tree/master/example/koa-session

I'll update the docs prior releasing the new version (which will be around the end of this week)

This solves the session issues.


As for the koa-router module take a look at the examples again https://github.com/simov/grant/tree/master/example/koa-session there in my consumer application I'm using koa-route instead. So using koa-router is not required. As far as the middleware order goes, you should put session and grant on top, if mounting koa-router before grant doesn't work, then you should put it after it.

from grant.

simov avatar simov commented on April 27, 2024

@bitinn check out this commit 908b9a8

The Koa middleware no longer depends on koa-router, so you can mount it in your app wherever you want. I'll let you know when the new release is out.

from grant.

bitinn avatar bitinn commented on April 27, 2024

Thx, i will get to test it soon :)

from grant.

simov avatar simov commented on April 27, 2024

@bitinn version 3.0.3 is published on NPM. Thanks for the feedback 👍

from grant.

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.