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
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
  • 2,674
  • 3
  • 19
  • 35
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,875
  • 6
  • 61
  • 93
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
  • 2,619
  • 3
  • 18
  • 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,424
  • 18
  • 24
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,143
  • 10
  • 54
  • 123
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
  • 2,432
  • 2
  • 18
  • 28
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
  • 2,619
  • 3
  • 18
  • 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,972
  • 5
  • 30
  • 49
0
votes
1 answer

InversifyJS for ES6

Are there any examples around using this ico with ES6 rather than Typescript for back-end Node/Express ? I followed a few Typescript examples but nothing for ES6. I've looked at the generated ES5 from Typescript but this seems a backwards step
Rory
  • 1,442
  • 4
  • 21
  • 38
0
votes
1 answer

How to create a injected and a const instance?

An instance of class A needs to obtain the dependence of an instance of a class O, but to be singletons for others. How to do it? @injectable() class O{} // A must be single instance! @injectable() class A{ constructor(o: O){ …
user220409
  • 184
  • 1
  • 17
0
votes
1 answer

Dependency Injection creating new object everytime an api is called

Everytime I'm calling an api in inversify-express server the dependency is creating a new object everytime var kernel=new…
Archit Dwivedi
  • 416
  • 4
  • 9
0
votes
4 answers

Typescript 2.0 unknown compiler error

I'm getting this error Unknown compiler option 'lib'. (5023) Unknown compiler option 'types'. (5023) I removed typescript from node_module didn't work used npm uninstall typescript and npm install -g typescript didn't work again used npm…
user4092086
  • 986
  • 3
  • 12
  • 24
0
votes
2 answers

Why does Typescript not compile this InversifyJS decorator?

I'm copying the Inversify documentation almost exactly (version 1.2.2) and it fails to compile, giving me Typescript error TS1238. Why? 'use strict'; import './tools/typescriptImports'; import IServer = require('./iServer.ts'); import IDatabase =…
Richard
  • 14,798
  • 21
  • 70
  • 103
-1
votes
1 answer

Inversify - Http Context is always an empty object

i hope you can help me, i'm trying to build an API using inversify and inversify-express-utils. So, I already created my controllers and the API is working fine and no problems so far, but when I try to access to the httpContext property that comes…
1 2 3
13
14