Has anyone got inversify to work with this package?

See original GitHub issue

Just trying to get useContainer to work with inversify not injecting anything at the moment.

code looks like this:

index.ts

const app: express.Express = express();
useContainer(container);
useExpressServer(app, {
   controllers: [__dirname + "/controllers/*.ts"],
});

container.ts

let container = new Container();

container
  .bind<IController>(TYPES.ChangelogController)
  .to(ChangelogController)
  .whenTargetNamed("ChangelogController");

export { container }

Getting errors:

Error: No matching bindings found for serviceIdentifier: ChangelogController
Registered bindings:
 ChangelogController - named: ChangelogController
at ActionMetadata.callMethod .../packages/..../src/metadata/ActionMetadata.ts:254:39)  
at ..../packages/..../src/RoutingControllers.ts:123:142

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pleerockcommented, Jun 6, 2017

Looks like its solved

1reaction
rucascommented, Jun 4, 2017

Never-mind I got it to work by doing this:

container
  .bind<IController>(ChangelogController)
  .toSelf();
Read more comments on GitHub >

github_iconTop Results From Across the Web

inversify/InversifyJS - Gitter
Hey guys! I'm trying to write unit tests for a graphql resolver with a dependency on a service using type-graphql, inversify, and jest....
Read more >
Inversify cannot inject class with dependencies - Stack Overflow
I 'm a bit pressed on time, so I can't dive further into it for now. However, this should work at least: typescript...
Read more >
Dependency injection: setting up InversifyJS IoC for Typescript ...
To implement DI in the project I'm going to use InversifyJS as the IoC (inversion of the control) container. First, we need to...
Read more >
Why I Don't Use a DI Container | Node.js w/ TypeScript
Instead of a DI Container, I just package features by component and use logical ... I've been waiting for the moment where my...
Read more >
Typescript dependency injection: setting up InversifyJS IoC for ...
Add inversify to the project. To implement DI in the project I'm going to use InversifyJS as the IoC (inversion of the control)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found