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
4
votes
0 answers

How to use InversifyJS with Web Components custom elements, considering contextual bindings and named and tagged decorators?

I'm working on a small Single Page Application with Web Components custom elements and I wanted to use InversifyJS for dependency injection. This posed an interesting challenge as custom elements are instantiated by the browser and require a…
4
votes
2 answers

Inversify + Typescript 5: TS1239: Unable to resolve signature of parameter decorator when called as an expression

One of my projects uses Inversify for dependency injection like this: @injectable() export class MyClass { constructor( @inject(OtherClass) private otherClass: OtherClass, ... ) { } This always worked fine and should be OK according to the…
floele
  • 3,668
  • 4
  • 35
  • 51
4
votes
1 answer

Reset scoped container in inversifyjs

I'm implementing a scoped container architecture such that a new container is created for every Express request (or apollographql request). I have a lifecycle method that can be called after we're done sending the response, which is good for…
4
votes
1 answer

How to bind instance to inversify container

I'm using inversify with inversify-express-utils. I have a quite usual inversify/express setup. Controller Service A module B module B module is a class that looks like this: import { injectable } from 'inversify'; import SpellCorrector…
matewilk
  • 1,191
  • 1
  • 13
  • 27
4
votes
0 answers

Inversify typescript generic factories

I use inversify in a typescript project. I created a inversify.config.ts file and made some inversify factories. Here is an exemple of one of my factories…
TCH
  • 421
  • 1
  • 6
  • 25
4
votes
1 answer

InversifyJS @multiInject not working, throws error "Ambiguous match found for serviceIdentifier"

I am using inversifyJs for DI in my typescript project. When using the decorator @multiInject, I am getting the error "Ambiguous match found for serviceIdentifier". I am following this example…
4
votes
1 answer

inversify help required and why do we need it?

Can you recommend any great learning resources on inversify in typescript? I have looked at http://inversify.io/ and have followed the example but am not grasping how it really works or why I need it. A great video learning resource would be great…
Hello-World
  • 9,277
  • 23
  • 88
  • 154
4
votes
1 answer

InversifyJS - Inject service to express middleware

I am using inversify, inversify-binding-decorators, and inversify-express-utlis and have problem with express middleware. I am calling my middleware in this way: let server = new InversifyExpressServer(container); ... server.setConfig((app) => { …
templaris
  • 221
  • 5
  • 11
4
votes
1 answer

The inRequestScope is not working as expected

Help using inRequestScope inversifyJS Eg: container.bind(Types.MysqlTransactionManager).to(MysqlTransactionManager).inRequestScope() ... container.get(Types.MysqlTransactionManager)//call the…
Iuri Brindeiro
  • 143
  • 1
  • 8
4
votes
2 answers

How to support "per request" scope

I want to get the user token from the middlewares and injected into controller, is it possible? class TaskController { @inject private currentUser @Post('/tasks') addTask() { if (!hasPermission(currentUser)) throw new…
Ron
  • 6,037
  • 4
  • 33
  • 52
3
votes
0 answers

inversifyJs error: Error: No matching bindings found for serviceIdentifier: String

In mine application using inversify for DI conteinerisation have a abstract class @injectable() export abstract class Name { tableName: string; constructor( @inject("DatabaseService") public db: DatabaseService, …
3
votes
1 answer

CRA + Inversify @inject Module parse failed: Unexpected character '@'

This is the error that I get ./src/core/providers/todoApi/TodoApiProvider.ts 10:14 Module parse failed: Unexpected character '@' (10:14) File was processed with these…
Alan Yong
  • 993
  • 2
  • 12
  • 25
3
votes
1 answer

Error during initialization: No matching bindings found for serviceIdentifier: Symbol(LicencesService)

I am getting error while compiling the code : No matching bindings found for serviceIdentifier: Symbol(LicencesService) Following is the code associated with the issue. The issue is with the constructor of the HTTP on server.ts file, how do I…
Mudit Agrawal
  • 325
  • 1
  • 3
  • 14
3
votes
1 answer

Unable to catch errors globally from inversify-express-utils controllers

I'm using this package https://github.com/inversify/inversify-express-utils for a nodejs app, and I want to have a place to handle errors from any controller, the way I know is to use express error handler, but it doesn't seems to work in this case-…
Avishay28
  • 2,288
  • 4
  • 25
  • 47
3
votes
2 answers

pass type to dependency injection container

I am supporting multiple databases without using ORM tools. For this example I will show an example for Postgres and MSSQL UserQueries I have an interface IDataBase with multiple databases implementing this interface. @injectable() export class…
user9945420
1
2
3
13 14