Questions tagged [tsyringe]

40 questions
0
votes
1 answer

Getting Experimental support for decorator error when using tsyringe @injectable

I'm using tsyringe for dependency injection and trying to run unit tests. The class is in ts and the test file is in js. When I try to run my tests by executing TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha -r ts-node/register src/**/*.test.js I…
0
votes
0 answers

Tsyringe returns undefined instance of a service in controller

I am having trouble using tsyringe DI with controller, service and repository I have three classes: UserController, UserService and UserRepository. For service and repository, I am using interface for DI (IUserService and IUserRepository) the DI for…
0
votes
2 answers

express/tsyringe TypeError: Cannot read properties of undefined (reading 'service')

I'm working on small project for school and I'm new to express and dependency injection. I started this little project just to get an idea of how it works. I tried to understand this error for hours but I didnt find something about it. Thank you for…
Mlouden
  • 49
  • 6
0
votes
1 answer

Nodejs / Typescript: Using EventEmitter between multiple classes

I am using tsyringe as a dependency container and I have 2 classes. AccountingService and TransactionService. I am listening to the event triggered in TransactionService so that I can update the data in AccountingService using accountingRepository…
Bellaraus
  • 3
  • 2
0
votes
1 answer

Pragmatical ways to determine a week and automatic functions on a Node.js back end

I’m developing a backend server, using Postgres as my database for a friend’s game project. Everything is going well but there are a couple of features that I want to add which I’m not knowledgeable about yet. The game works with ranks. Every day…
RicCJ
  • 1
0
votes
1 answer

How to make tsyringe (dep injection lib) resolve classes that have dependencies?

I am clearly misunderstanding how TSyringe is supposed to resolve classes with dependencies. I created a minimal repro. In my index.tsx, I do as they indicate in the docs and import reflect-metadata. This example works if I inject a singleton class…
Edy Bourne
  • 5,679
  • 13
  • 53
  • 101
0
votes
1 answer

TSyringe and TypeORM importing Database dependencies BEFORE other dependencies

I'm facing one problem, in which I have lots of Repositories(which they are TS Classes that implements one interfaces, they are typeorm repositories class) and I use TSyringe to handle all my dependencies in my API Here is an example of one…
0
votes
2 answers

TSyringe inject all classes that implements some interface

I've been looking if it's possible for TSyringe to inject all classes that implements some interface (or extends from an abstract class), like this: @injectable() export interface IService { foo(): void; } @injectable() export class Service1…
0
votes
1 answer

Error injecting dependency into controller with tsyringe

I am using express and tsyringe for dependency injections. When I try to use the service dependency on my controller I get an error UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'addressService' of undefined in file…
0
votes
1 answer

Cannot inject the dependency "modelRepository" at position #0 of "GetModelService" constructor. Reason: Cannot read property 'name' of undefined

i've been using sequelize-typescript, tsyringe on a refactor work here and i got a pretty interesting bug here. Well normally all of my repository containers is being registered normally and instanced properly with the follow settings: i import the…
Pix
  • 31
  • 1
  • 7
1 2
3