jaredhanson / electrolyte

Elegant dependency injection for Node.js.
MIT License
564 stars 61 forks source link

node module with hyphens #29

Open slicc opened 9 years ago

slicc commented 9 years ago

When a node module has hyphens I can't inject it. E.g. documentdb-q-promises, when I add this as a parameter to my module I get a js issue. Is there any way to inject node modules with hyphens?

thejinxters commented 8 years ago

@slicc -- I know this is a bit late, but the ['@require'] annotation injects your dependencies in the order you specify

Here is an example:

exports = module.exports = (authController, passport, bearer) ->
  BearerStrategy  = bearer.Strategy
  # Bearer Strategy for Token-based Auth
  passport.use 'bearer', new BearerStrategy (token, done) ->
    authController.validToken(token, done)

  return passport

exports['@require'] = ['controllers/auth_controller','passport', 'passport-http-bearer']

So in this example, passport-http-bearer maps directly to bearer because it is the 3rd dependency listed.