Inversifyjs: Not working Example express-utils

Created on 22 Jun 2016  路  10Comments  路  Source: inversify/InversifyJS

Expected Behavior

The example in the Readme should work

Current Behavior

I nearly exactly copied the example from the readme, but always got a error.

Possible Solution

Update Readme

Steps to Reproduce (for bugs)

  1. Use the Readme example
  2. Start the Server
  3. Try to load the new Controller

Context

Tried to setup a small project for testing. For me it helped to take a look into the tests and change my kernel config like there:

let kernel = new Kernel();
kernel.bind<AboutController>('AboutController').to(AboutController);

Your Environment

  • Version used: 1.0.0-alpha.3
  • Environment name and version (e.g. Chrome 39, node.js 5.4): NodeJS 6.2.0
  • Operating System and version (desktop or mobile): Linux Ubuntu 15.10
  • Link to your project: None

Stack trace

When it is used like the readme says

Error: No bindings found for serviceIdentifier: AboutController
    at Kernel._getActiveBindings (path to project/inversify/lib/kernel/kernel.js:169:23)
    at Kernel._plan (path to project/inversify/lib/kernel/kernel.js:186:29)
    at Kernel._planAndResolve (path to project/inversify/lib/kernel/kernel.js:157:29)
    at Kernel._get (path to project/inversify/lib/kernel/kernel.js:149:27)
    at Kernel.get (path to project/inversify/lib/kernel/kernel.js:80:21)
    at handler (path to project/inversify-express-utils/lib/route-container.js:37:39)
    at Layer.handle [as handle_request] (path to project/express/lib/router/layer.js:95:5)
    at next (path to project/express/lib/router/route.js:131:13)
    at Route.dispatch (path to project/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (path to project/express/lib/router/layer.js:95:5)
Accepting PRs Example bug docs

Most helpful comment

Hey guys, thanks a lot for the contributions and help!

I took a look at https://github.com/inversify/inversify-express-example and it looks good. The only problem is that after @remojansen makes the 1.0.0-beta.1 release, the way the controllers are bound to the kernel will need to change slightly, see https://github.com/inversify/inversify-express-utils/pull/3.

Otherwise it is good. In the future it would be nice to add examples for using middleware (maybe passport?) and a vanilla JavaScript example.

All 10 comments

This example has not been updated for some time :( My main goal right now is to finish the 2.0.0 release. I will then focus on all the side projects and the examples. You can try to help with this but I would recommend you to wait until https://github.com/inversify/InversifyJS/issues/256 is completed to avoid re-doing work.

Okay, will take a look at the issues later today and look if I fined something.
Currently working on a example for express. Possible that a PR for it comes today :)

Great :+1: My plan is to release [email protected] and [email protected] before Monday.

What is there todo in inversify-express-utils? Updating the inversify dependencies?

I just finished it https://github.com/inversify/inversify-express-utils/pull/4 I also need to update https://github.com/inversify/inversify-dts and release both. I just created https://github.com/inversify/inversify-express-example maybe you can start by moving the code to that repo?

As soon as I am ready with it I will make a PR

Hey guys, thanks a lot for the contributions and help!

I took a look at https://github.com/inversify/inversify-express-example and it looks good. The only problem is that after @remojansen makes the 1.0.0-beta.1 release, the way the controllers are bound to the kernel will need to change slightly, see https://github.com/inversify/inversify-express-utils/pull/3.

Otherwise it is good. In the future it would be nice to add examples for using middleware (maybe passport?) and a vanilla JavaScript example.

Thanks.
In the next few days I will create more examples. This was the most basic one I could think of.

This issue can now be closed right? If you want more examples we can create new issues for each example?

I think yes. With the updated Readme it works

Was this page helpful?
0 / 5 - 0 ratings

Related issues

inaiei picture inaiei  路  4Comments

remojansen picture remojansen  路  3Comments

remojansen picture remojansen  路  4Comments

hexa00 picture hexa00  路  3Comments

rashtao picture rashtao  路  3Comments