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
3
votes
1 answer

typescript dependency injection with little footprint

I am new to nodejs and typescript, coming from C#. I want to use dependency injection in my project and found that the most popular package is inversify. I started using it but I don't like the fact that I have to add decorators all over. for…
Mithir
  • 2,355
  • 2
  • 25
  • 37
3
votes
1 answer

What does it mean when a class implements itself in Typescript

I'm trying to add dependency injection to a plain Typescript project, found an npm package called inversify. So looking at the examples I came across this code: import { Container, injectable, inject } from "inversify"; @injectable() class Katana…
user3531149
  • 1,519
  • 3
  • 30
  • 48
3
votes
2 answers

multiInject in Nest.js

In Inversify.js there is multiInject decorator that allow us to inject multiple objects as array. All objects' dependencies in this array resolved as well. Is there any way to achieve this in Nest.js?
Artsiom Miksiuk
  • 3,896
  • 9
  • 33
  • 49
3
votes
1 answer

inversify typescript factory binding returns union type?

I'm using inversify v4.13.0 and Typescript, both of which I'm new to. I have a Logger interface: interface Logger { log(level: string, message: string, meta?: any): void; } a TYPES file: const TYPES = { Config: Symbol.for('Config'), …
lostdorje
  • 6,150
  • 9
  • 44
  • 86
3
votes
2 answers

Inversify partial injection

How partial properties injection can be done with Inversify? Let's say we have class class MyClass { constructor( @inject(EXTERNAL_A) private externalA: ExternalClassA, private b: string ) {} } How can I use this MyClass…
3
votes
1 answer

expressjs inversify controller middleware error

I'm building a very little rest api using nodejs, express and inversify. Here it is my working code: index.ts const container = new Container(); container.bind(Types.Controller) .to(MyController) …
Fabry
  • 1,498
  • 4
  • 23
  • 47
3
votes
1 answer

InversifyJS: dependency instantiation per HTTP Request

I'm using Inversify.JS in a project with Express. I would like to create a connection to a Neo4J Database, and this process has two objets: The driver object - Could be shared across the application and created one time only The session object -…
3
votes
1 answer

Missing @inject annotation, which isn't missing in inversify with an extending class

I'm having a problem which seems a bit hard to put into a title, which is why you've gotten this beast of a title. I get an error stating: Error: Missing required @inject or @multiInject annotation in: argument 0 in class SceneRepository.. This…
Pjetr
  • 1,372
  • 10
  • 20
3
votes
1 answer

Factory with parameters in InversifyJS

I'm using InversifyJS with TypeScript. Let's say I have a class which has a mixture of injected and non-injected constructor parameters: @injectable() export class MyClass { constructor( foo: Foo, // This thing isn't injectable …
Tim S
  • 689
  • 6
  • 16
3
votes
2 answers

InversifyJS - Inject middleware into controller

I'm using inversify-express-utils using the shortcut decorators (@GET, @POST...) within a node application. Is it possible to inject middleware into the controller to use with these decorators? Example of what I'm trying to achieve (doesn't…
carlcheel
  • 621
  • 6
  • 11
3
votes
1 answer

InversifyJS - injectable is not a function

I'm trying to set up a NodeJS/TypeScript project using InversifyJS but I'm having some trouble getting off the ground. I've been looking at this for the past couple of days and can't figure out the issue. Everything builds correctly, but when I…
bbogovich
  • 341
  • 1
  • 7
2
votes
1 answer

Inversify throws "Ambiguous match found for serviceIdentifier" when a second binding is attempted

Did my diligence and the following are not the scenario I am experiencing. InversifyJS @multiInject not working, throws error "Ambiguous match found for serviceIdentifier" Using Inversify to do a Multiinject of a class with constant and injected…
Itanex
  • 1,664
  • 21
  • 33
2
votes
0 answers

Inversify decorator in abstract class doesn't work with protected constructor

Decorator function return type 'abstract new (...args: never) => unknown' is not assignable to type 'void | typeof BaseController'. Types of construct signatures are incompatible. Type 'abstract new (...args: never) => unknown' is not…
2
votes
0 answers

Using inversifyjs to inject container bindings to an instance of an existing object

Basically I would like to be responsible for the construction of the object, then use inversify to bind properties that are decorated to @inject. I thought I could use createChild to bind the type to a value using toConstantValue or even…
csharptest.net
  • 62,602
  • 11
  • 71
  • 89
2
votes
0 answers

How do I insert loaders to my inversifyjs project?

I'm learning inversifyjs, and I'm trying to do the example from inversify package. And I stumble upon an issue that you can see below: Module parse failed: Unexpected character '@' (30:14) File was processed with these loaders: *…
1 2
3
13 14