Skip to content
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

Error when upgrading koa-compose to 3.0 #31

Closed
ppascher opened this issue Oct 24, 2015 · 2 comments
Closed

Error when upgrading koa-compose to 3.0 #31

ppascher opened this issue Oct 24, 2015 · 2 comments

Comments

@ppascher
Copy link

Hello,

when I update koa-compose to the recently released version 3.0 I keep getting the following error:

TypeError: downstream.call(...)[(intermediate value)] is not a function
      at Object.<anonymous> (/projects/intranet_redux/backend/node_modules/koa-mount/index.js:58:23)
      at [object Generator].next (native)
      at Object.<anonymous> (/projects/intranet_redux/backend/node_modules/koa-mount/index.js:60:14)
      at [object Generator].next (native)
      at Object.dispatch (/projects/intranet_redux/backend/node_modules/koa-router/lib/router.js:331:14)
      at [object Generator].next (native)
      at Object.<anonymous> (/projects/intranet_redux/backend/node_modules/koa-mount/index.js:58:23)
      at [object Generator].next (native)
      at Object.serve (/projects/intranet_redux/backend/node_modules/koa-static/index.js:41:14)
      at [object Generator].next (native)

I tried looking at the commits from koa-compose since 2.3 but couldn't figure it out.
I currently use it like this

// protected route - check if user has a valid token & permissions for ressource
app.use(mount('/api/v1/', compose([jwt({secret: publicKey, algorithm: 'RS256'}), permissionCheck(), apiRoutes.middleware()])));
@derek-duncan
Copy link

I ran into this same error today, but I found a solution you might find useful. First off, the error is occurring because koa-compose 3.0 has been upgraded to koa 2.0. Notably, ctx is now being passed as the first argument in middleware vs being referenced with this. That's why .call is breaking in this case.

I've forked koa-mount and updated the module to work with Koa 2.0. I'm not sure if this should be submitted as a PR, so I'll just link it here. Hope it helps!

koa-mount for Koa 2.0

@ppascher
Copy link
Author

ppascher commented Nov 3, 2015

Thanks alot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants