I'm trying to using awilix dependency injection container on mediatr-ts, but when a point the mediatorSettings.resolver to the class, mediatr-ts stops to handle the messages, the error TypeError: handler.handle is not a function throws.
here is my app.ts:
import { InjectionMode, asClass, asValue, createContainer } from "awilix";
import { loadControllers, scopePerRequest } from "awilix-express";
// this is the very first code of the app
class InversifyResolver implements IResolver {
resolve<T>(name: string): T {
var res = container.resolve(name);
return res;
}
add(name: string, instance: Function): void {
container.register({
[name]: asValue(instance)
});
}
remove(name: string): void { }
clear(): void { }
}
mediatorSettings.resolver = new InversifyResolver();
const container = createContainer({ injectionMode: InjectionMode.CLASSIC }).register({
loggerService: asClass(MyLoggerService).scoped()
});
app.use(scopePerRequest(container));
app.use(loadControllers('features/*/routes.js', { cwd: __dirname }))
then if you try to send any mediator message, the error TypeError: handler.handle is not a function throws...
I also tried to inject the mediator and work with it to dispatch messages, the error persists.
Any help?
I'm trying to using awilix dependency injection container on mediatr-ts, but when a point the mediatorSettings.resolver to the class, mediatr-ts stops to handle the messages, the error
TypeError: handler.handle is not a function
throws.here is my app.ts:
then if you try to
send
any mediator message, the errorTypeError: handler.handle is not a function
throws... I also tried to inject the mediator and work with it to dispatch messages, the error persists. Any help?