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/

156 questions
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
  • 9
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
  • 659
  • 1
  • 13
  • 28
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
  • 27,053
  • 14
  • 78
  • 109
0
votes
1 answer

What is a real-world way of allowing a mocha test to stub/mock fs so I can test a function without it accessing the disk?

So my code looks like this: import FsAsyncFactory from '../fs/FsAsyncFactory' import ObjectHelper from '../utils/ObjectHelper' import Config from './Config' export class ConfigHelper { // this is the function under test public static async…
Force Hero
  • 1,456
  • 2
  • 12
  • 25
0
votes
2 answers

Reflect is not defined when my project is deployed to the server

I'm trying to deploy my node.js project to the openshift server, My project runs fine on my local machine but when deployed on the server it complains as follows /opt/app-root/src/node_modules/inversify/lib/annotation/decorator_utils.js:22 if…
0
votes
1 answer

How share a transient object instance between multiple injected instances?

In Inversify, what is the best approach to have a single object instance (with transient life) shared between multiple objects. So let us say we have: @injectable() class Foo1 { @inject("bar") private bar: IBar; } @injectable() class Foo2…
lorefnon
  • 12,112
  • 4
  • 54
  • 87
0
votes
1 answer

Using Inversify to do a Multiinject of a class with constant and injected parameters

I have a Typescript class called insuranceController that accepts a multi inject parameter like so: @injectable() export class InsuranceController implements IInsuranceController { private policies: IInsurancePolicy[]; …
PRS
  • 667
  • 7
  • 22
0
votes
1 answer

Make node package injectable

How to make node package (class from node_modules) injectable? I use inversify in my app and I want to bind Validator.ts class to my container. How can I do it? const container = new Container(); container.bind(Validator).toSelf(); Is not…
tBlabs
  • 1,775
  • 3
  • 14
  • 22
0
votes
1 answer

How can I pass values to a class constructor with inversifyJS?

Hi have a typescript test project with inversify and requirejs that can be cloned from: https://github.com/ahedreville/ioctest.git His package.json is a follows { "name": "ioctest", "version": "1.0.0", "description": "Test of an IoC with…
alhpe
  • 1,164
  • 13
  • 19
0
votes
1 answer

inversify: how to handle binding to a generic interface/class

I am using inversify for an mean stack application developed with typescript. Following the instructions here at this url: https://www.npmjs.com/package/inversify, I created the inversify.config.ts file and added the code relevant to my needs. I…
user1790300
  • 2,245
  • 6
  • 36
  • 97
0
votes
1 answer

How to use Inversify with Mocha

I'm using Inversify for Dependency Injection in my TypeScript Node.js application. This works great when actually running the app. However, the @injectable() annotation seems to have crippled my tests. When running tests, I now get an error…
Alec
  • 1,126
  • 1
  • 10
  • 23
0
votes
1 answer

inversify.js resolve by name

I want to create little CQRS framework for my Typescript Node.js project. I wish to resolve class by it's name from inversify.js container. I need something like that: let x = container.get("Foo"); where Foo is regular class and container is…
tBlabs
  • 1,775
  • 3
  • 14
  • 22
0
votes
1 answer

How to inject code you don't control in InversifyJS

Is it possible to inject classes that you can't edit? It seems Inversify is heavily dependent on annotations/decorators but is there another way?
Cristian Vrabie
  • 3,770
  • 5
  • 26
  • 46
1 2 3
10
11