Questions tagged [inversifyjs]

InversifyJS is a lightweight IoC container written in TypeScript.

InversifyJS is a lightweight pico inversion of control (IoC) container for TypeScript and JavaScript apps. A pico IoC container uses a class constructor to identify and inject its dependencies.

InversifyJS is easy to integrate with the majority of existing JavaScript frameworks and encourage the usage of the best OOP and IoC practices.

You can learn more about InversifyJS at http://inversify.io/

197 questions
0
votes
1 answer

InversifyJS: Inject a specific concretion from a multi-inject definition

Let's assume I use multi-injection in InversifyJS like in the official example: container.bind("Ninja").to(Ninja); container.bind("Weapon").to(Katana); container.bind("Weapon").to(Shuriken); Is it possible to inject a…
Dominic
  • 4,572
  • 3
  • 25
  • 36
0
votes
0 answers

Inversify container is undefined in the runtime

Cannot get an instance from the inversify container when I try to execute getNamed(). The container is well defined, typescript does not complain, I can see that the type of the import is "Container"; however, in the runtime container is…
0
votes
1 answer

How to fixed the error [ERR_ASSERTION]: Constructor already exists! ("inversify-restify-utils": "^3.4.0") and ( "inversify-restify-utils": "^3.4.0")

node_modules/restify-errors/lib/index.js:67 assert.equal(typeof module.exports[name], 'undefined', ^ AssertionError [ERR_ASSERTION]: Constructor already exists! "inversify": "^4.13.0", "inversify-binding-decorators":…
0
votes
1 answer

Error handling in an inversify controller

I'm using the inversify-express-utils package. Suppose I have a controller action that returns a User entity: @httpGet("/:id") public async getUser(): Promise { try { const id = this.httpContext.request.params.id; return…
lonix
  • 14,255
  • 23
  • 85
  • 176
0
votes
1 answer

Do I need reflect-metadata package with inversify if I use express and angular?

The inversify docs say The reflect-metadata polyfill should be imported only once in your entire application because the Reflect object is mean to be a global singleton. More details about this can be found here. If your environment don't support…
lonix
  • 14,255
  • 23
  • 85
  • 176
0
votes
1 answer

Inversify dependency injection not injecting dependencies into constructor

I have followed the guide on npm and github for inversify to configure dependency injection in my Typescript project. I have a controller, a service and a router. The service is injected into the controller via constructor injection and the…
0
votes
3 answers

Getting 404 from inversify-express-utils controller

I'm struggling to get an inversify-express-utils service properly configured. I'm trying to use two controllers, but only one of them seems to be discovered by inversify. With my current configuration, only helloController seems to be registering.…
MJ.
  • 1,269
  • 4
  • 12
  • 24
0
votes
1 answer

InversifyJS injecting express.Application

I'm trying to implement InversifyJS in one of my Express projects, everyting is working perfect except the websockets. The WebsocketServer requires a built server instance, and I store connections in the express object, like this: const port =…
SkarXa
  • 1,184
  • 1
  • 12
  • 24
0
votes
2 answers

Inversify composition root for constructor injection

I am from c# background. I am new to Angular 6. I learnt that there is lib similar to ninject for DI. Inversify. I tried to use it in an application. I did configure Bindings and TYPES. TYPES.ts const TYPES = { IAppService :…
MARKAND Bhatt
  • 2,428
  • 10
  • 47
  • 80
0
votes
1 answer

Can't import exported functions

I am having strange issues with Typescript when I import things from a file which exports them. Sometimes I will export a function, then import it to another file, then I use the function and it is not a function anymore. When I define the function…
mr haven
  • 1,494
  • 1
  • 17
  • 28
0
votes
1 answer

Inject specific values into object constructor

I have several implementations of an interface and they each need their own configuration injecting into the constructor. My question is if I can somehow hook the dependency injection system in NestJS (presumably Inversify) to inject not just a…
0
votes
1 answer

Typescript InversifyJS - How to set variable value from maint.ts and get the value from a controller

I am new to Typescript and InversifyJS. What I am trying to achieve is to share variable value across multiple files. I am setting the value on the server startup on main.ts and I am trying to fetch that value from a controller. What I did is I…
Jed Nocum
  • 80
  • 11
0
votes
1 answer

InversifyJS with webpack, library size is much more than 4k

I am new with InversifyJs. It looks great and I am trying to implement it into my project. On the official website (http://inversify.io/) I read that it is a 4k library and this is fine because I have to keep the size of the bundle as smaller as…
0
votes
1 answer

constructor injection using inversifyJS and Alsatian test framework

Hoping someone can guide me in the right direction here I'm using inversifyJS with Alsatian testing framework basically the design calls for utilising several services, including database and other api clients, I thought it'd be a good idea to get…
Danish
  • 741
  • 4
  • 17
  • 31
0
votes
1 answer

Can I avoid using symbols/strings with Inversifyjs?

I want to be able to simply specify what is needed without adding strings or symbols. This seems to work for declaring the binding: container.bind(Shuriken); But I get a run-time error if I don't use @inject and don't know what to put in…
Jason Goemaat
  • 28,692
  • 15
  • 86
  • 113