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

How to initialize and inject dependency like RpcClient?

I'm initializing an RPCClient in the Inversify container: container.ts: .... container.bind(TYPES.RPCClient).to(RPCClient); .... In main.ts I'm initializing this RPCClient: ... container.get(TYPES.RPCClient).initialize({…
0
votes
1 answer

How to inversify sequelize instance

I have a sequelize-typescript that defines a mysql db object: const DBInstance = new Sequelize(config.db.database, config.db.username, config.db.password, { host: config.db.host, dialect: config.db.dialect as Dialect, repositoryMode:…
0
votes
1 answer

Testing the Container/ContainerModule in InversifyJs

I'm wondering if anyone has any guidance on how to test that IoC wiring is as intended. For my use case, I'm using InversifyJS with Typescript, and Jest for testing. I have used Inversify ContainerModules to allow my application to be split up, and…
Dave Meehan
  • 3,133
  • 1
  • 17
  • 24
0
votes
0 answers

unable to set values from mocky.io using axios in react

I'm trying to use mocky.io to get mock values but here i am unable to assign the response data value to _user_id or any other variable, it's showing as undefined on console.log, when i do console.log for response object i get the json object but…
0
votes
0 answers

How to use InversifyJS to inject named constructor parameters?

I'm new to Inversify but want to utilise it in the codebase I'm working in. In this codebase, the dependencies are injected via an args object as a means to simulate named constructor parameters. What would be the best way to decorate this object…
pantryfight
  • 338
  • 1
  • 3
  • 13
0
votes
0 answers

Making parent controller as base router path for a particular module in inversify express.js

I have multiple modules and want to club them under one route path based on…
Mr X
  • 1,637
  • 3
  • 29
  • 55
0
votes
0 answers

Socket Not working if we import controller from inversify but if we import the controller from inversify-socket-util it is work

Socket Not working if we import controller from inversify but if we import the controller from inversify-socket-util it is works. unable to apply middleware in controller if we import controller from inversify-socket-util not works rest of the…
0
votes
1 answer

How to define third-party dependency in TypeDI or Inversify

I am looking into using Dependency Injection for a TypeScript/Node project, which is a new language/framework for me. TypeDI and Inversify came up as options, but I couldn’t figure out in either case how to tell the container how to create an…
Jed
  • 494
  • 1
  • 6
  • 15
0
votes
1 answer

Get Async Dependency globally Inversify

I wish to get an asynchronous dependency at the top level, without having to use top level awaits. Currently I am using a temporary hack by declaring getService(), an asynchronous function, in the controller file. However, by doing so I have to call…
0
votes
0 answers

Inversify - Jest - call API endpoint to test auth guard

Iam using Inversify & inversify-express-utils for building an Express Server. I am new to testing(Jest). I need to call API instead of calling the controller class so that I can test the AuthGuard and RolesGuard. I tried using supertest library. Iam…
0
votes
0 answers

Inversify dependency inversion , undefined value in injected class

I am trying to inject Typeform data source into my Student repository. container setup container.bind(TYPES.PGContext).to(PGContext); Pg context class, connect called in index.js @injectable() export class PGContext { public _pg:…
0
votes
0 answers

Object is undefined in dependency injection

I'm developing an api server with App sync, node.js, typescript and serverless framework I use inversify.js to make a di container. Here's the issue I am facing. First of all, I define types. SAMPLE_USECASE: Symbol.for('SampleUseCase'), …
kappa
  • 107
  • 1
  • 12
0
votes
1 answer

Why singleton pattern is safety on single thread?

While using theinversifyJS library, I saw a statement that the singleton pattern is safe because node.js is single-threaded. How does single-threading benefit from singletons over multithreading?
aryang
  • 73
  • 1
  • 7
0
votes
1 answer

InversifyJS + TypeScript + Ejected CRA: issues with importing files with interfaces

Code available here: https://github.com/rtrocca/test-inversify-cra I created a simple React application with CRA and the TypeScript template and ejected the app. I then added the files for the Ninja/Katana/Shuriken example. I also modified the babel…
Riccardo
  • 11
  • 2
0
votes
2 answers

Build React Native app with webpack instead of metro

My React Native app is part of a monorepo. All the "buildables" (api, backend, website) are written in TypeScript and built with Webpack. All of them use inversify. Therefore, the configuration to make decorators work is kind of duplicated in both…
c4k
  • 4,270
  • 4
  • 40
  • 65