fullcube / loopback-component-access-groups

Access controls for Loopback.
59 stars 21 forks source link

user-context is missing bluebird require. #3

Closed albertolobrano closed 8 years ago

albertolobrano commented 8 years ago

You are using bluebird but you are not requiring it in the user context. Fot that reason is failing witht he message : TypeError: Promise.join is not a function

Adding var Promise = require("bluebird");

solves the issue.

mrfelton commented 8 years ago

If you set 'global.Promise = require("bluebird")' as recommended by loopback I don't think you would have this issue.

albertolobrano commented 8 years ago

I may have missed that best practice in loopback: https://docs.strongloop.com/display/public/LB/Using+promises . To be honest, with you I prefer to declare all my dependencies and keep global as small as possible. Also, google uses require for bluebird inthe gcloud lib. Let me know what path you intend to follow. If we decide to set the global I think it should be highlighted in the docs.

mrfelton commented 8 years ago

The recommendation is based on using recent versions of Node, which has global Promise support built in. The standard approach in loopback 2.x to use an alternate Promise implementation such as bluebird was to override global.Promise.

In the upcoming loopback 3.x, they have moved to explicitly using bluebird within their own codebase, rather than using the global.Promise object. See https://github.com/strongloop/loopback/blob/master/3.0-RELEASE-NOTES.md#always-use-bluebird-as-promise-library

So with that in mind, I'd be happy to update this component to explicitly require bluebird throughout.

albertolobrano commented 8 years ago

Perfect. I will keep this ticket open and add the require to the other sripts

mrfelton commented 8 years ago

Thanks @albertolobrano