Questions tagged [awilix]

12 questions
1
vote
1 answer

AwilixResolutionError: Could not resolve 'run'

I'm having troubles with Awilix library. I am following the example in the documentation, but when I execute the function, it crash with this message: "AwilixResolutionError: Could not resolve 'run'". My code is like this: I have a file with the…
1
vote
0 answers

Making typesafe auto load modules container in Awilix Typescript

I'm using Awilix with Typescript. This is how I'm creating container const container = createContainer(); container.loadModules(["src/service/**/*.ts"], { formatName: "camelCase", resolverOptions: { injectionMode: InjectionMode.CLASSIC, …
Azeem Haider
  • 1,443
  • 4
  • 23
  • 41
1
vote
1 answer

mock a registered resolver in awilix

I have used awilix to be able to have dependency injection in javascript to be able to have easier test. but now I want to mock a resolver that is set in my container for only a set of tests In other words, I have a resolver that I want to mock it…
1
vote
0 answers

Awilix: Unable to resolve subclass with hard coded base class constructor parameters

I use the awilix library for achieving DI in my nodejs express project which used ES6 and nodejs 12.x. Let's say I have a base class and a subclass as follows class MyBaseClass { #collectionName; constructor(collectionName) { …
0
votes
0 answers

Class not being registered as dependency in awilix container or not being recognized as class

I don't know what is going on with the awilix container in a node-express app, but it is not working for new classes created in there, so basically what I did is created this dummy class import { CustomLogger, getLogger } from…
0
votes
0 answers

Awilix does not instantiate the class when executing it

I am trying to load modules as classes with the loadModules method but then when I execute a method of a container class, it appears as if it had not been instantiated because when accessing this from the class itself it is undefined. The name of…
Juan
  • 649
  • 1
  • 6
  • 11
0
votes
1 answer

How can I get Awilix loadModules to work, loads fine but no registrations?

I can't figure out why the loadmodules function does not work? Tested on 2 different machines to rule out environment. Added snippet below and link to project on github for reproduction. When I call the listModules function of Awilix it finds the…
Simon
  • 3
  • 1
0
votes
1 answer

Chaining functions using Repository Pattern with mongoose

I have a BaseRepository with the main methods that mongoose provides like this: class BaseRepository { constructor(model) { this.model = model; } async get(id) { return this.model.findById(id); } async find(filter) { return…
0
votes
1 answer

Jest doesn't recognize awilix container

Here is my code: babel.config.cjs module.exports = { plugins: ['@babel/plugin-transform-modules-commonjs'], presets: [['@babel/preset-env', { targets: { node: 'current' } }]] } jest.config.cjs module.exports = { globals: { …
Jakomo
  • 71
  • 6
0
votes
1 answer

Passing arguments with Awilix

I'm using Awilix in my code for Dependecy Injection and I have this User class. class User { constructor(opts){ this.validator = opts.validator } async validateUsername(username) { this.validator.username(username) …
0
votes
1 answer

Injecting dependencies in functions with awilix

I have been following component based strucutre for my projects and I have clone the repo for this purpose listed here Everything is fine and testable except services. So I decided to use awilix to inject dependencies in services. This is what I…
confusedWarrior
  • 938
  • 2
  • 14
  • 30
0
votes
1 answer

Depency Injection with "awilix"

I am learning dependecy injection using awilix. I tried the code below following a tutorial. I tried differently and each time I get the the kind of error below: //diSetup.js:13 var config = _ref.config; TypeError: Cannot read property…
Ben Jonson
  • 565
  • 7
  • 22