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
2
votes
2 answers

When to use container.get vs constructor @inject?

I'm new to using InversifyJS and I see a lot of basic examples of a class with a constructor using @inject for dependencies. Like this... export class Service { protected depA: DependencyA; protected depB: DependencyB; constructor( …
WhatAName
  • 23
  • 2
2
votes
1 answer

Getting 'ReferenceError: describe is not defined' error when going to start the application

I'm going to test typescript(inversify) code using jest. Below mentioned the code that use to test a controller method. describe('Test UserController',() =>{ let userService : UserServiceImpl = new UserServiceImpl(); let userController :…
2
votes
1 answer

Can't get property dependency injection to work in React project

I need some really basic dependency injection for a react project in a similar syntactical manner as in C# or Java. Using context or injection through props is not an option. I tried three solutions so…
Beltway
  • 508
  • 4
  • 17
2
votes
0 answers

InversifyJS purpose of using .toConstantValue

We already have inSingletonScope in Insersify JS. What is the purpose of using .toConstantValue? Could anyone let me know when do we want to use .toConstantValue?
2
votes
1 answer

Splitting inversifyJS config file into multiple files

I recently bumped into a backend project using Typescript and would like to implement IoC principle with the help of Inversify.js. Following the official documentation, I have one huge file named inversify.config.ts containing all my interfaces and…
stanleyad
  • 33
  • 5
2
votes
0 answers

How to use inversify.js in react redux application on the service layer

I would like to use inversify in react-redux application but only in the service layer and not via componenet I have the service of a setting that need to call to API (Http service) I would like a kind of provider that will give me the option to…
Tuz
  • 1,810
  • 5
  • 29
  • 58
2
votes
0 answers

Error: @inject called with undefined (...)

This is not the first time I work with Inversify, but never had a problem like such. Currently what I have in my project is just a bunch of decorated (properly, constructor injections) services, therefore I assume it's failing on building the…
pzaj
  • 1,062
  • 1
  • 17
  • 37
2
votes
1 answer

Inversify Express order routes

I'm using inversify-express-utils and I'm looking for a way to set an order for how my endpoints are matched. eg... using express. The router could have router.get('/users/me') router.get('/users/:userId') and the users/me endpoint would resolve…
Matt Wills
  • 676
  • 6
  • 11
2
votes
1 answer

InversifyJS - Inject a specif instance of an object

I started to use InversifyJS in Dynamics 365 development. To give you some context, Dynamics allows you to extend the platform writing custom business logic (using JS) and attach it to defined form events. In this example, I want to instantiate my…
Federico Jousset
  • 1,661
  • 14
  • 21
2
votes
2 answers

Inversify error, TypeError: Reflect.hasOwnMetadata is not a function

I am using inversify.js on a project and I decided to ship my data access classes as a separate NPM package. The package exports a class import { injectable, unmanaged } from 'inversify'; import { Document, Query, Model, model } from…
MrFoh
  • 2,693
  • 9
  • 42
  • 77
2
votes
0 answers

How does auto factory work in InversifyJS

In Autofac, auto-factory is generated factory for instantiating of classes with extra props which are cannot be resolved from container. But in InversifyJS it is something different. Could someone explain how / when should I use auto-factory in…
Igor Babkin
  • 509
  • 2
  • 6
  • 14
2
votes
0 answers

How to pool postgresql connections in nodejs with facade design pattern?

Hello i am writing simple web application using design similar to facade design pattern. Application is written in Typescript using nodejs, expressjs, node-postres and inversify. Let say i have this simple example Router.ts router.get('/test',…
2
votes
2 answers

How to achieve component scanning/auto discovery of Controllers using Inversify + inversify-express-utils

I am looking for a way to load my controller classes in Inversify that are annotated with @controller() from inversify-express-utils without needing to manage a hand crafted/manually constructed module of imports/exports. All of the examples I am…
Vigs
  • 1,286
  • 3
  • 13
  • 30
2
votes
0 answers

Getting 204 response before db action callback in expressjs, mongodb, inversifyjs

I want to add new document to the mongodb and get an inserted id as response with 201 status, but when db.insertOne called I get response with 204 status code before tap works. Here is my controller @controller('/stars') export class StarController…
Lilit
  • 21
  • 1
2
votes
0 answers

Node InversifyJS - Implementing middleware in all routes

In the documentation for Inversify Express Utils, the example shows how to override BaseMiddleware and then to inject it into a particular route in a controller as shown here. Is there a way to inject the middleware into every route without…
Evan Kaiser
  • 181
  • 8