inversify-express-utils
inversify-express-utils copied to clipboard
[inversify-express-utils] - No support for @controller on inevrfisy-binding-decorators?
Hey folks, I'm trying to implement here the inversify-binding-decorators together with the inversify-express-utils lib. Unfortunately, I wasn't didn't manage to make my @controller bindings to work properly. They do not seem to be recognized and I'm having to load all of them through a container.load
for example:
container.load(
buildProviderModule(),
assetControllerContainer,
collectionControllerContainer,
userControllerContainer,
trackerControllerContainer,
quoteControllerContainer,
indicatorControllerContainer,
portfolioControllerContainer,
companyControllerContainer,
orderControllerContainer,
newsControllerContainer
);
Expected Behavior
I was expecting to add a @provide() on any of my controllers and it's automatically bound into my inversify container, so I don't need to load all of them manually with container.load (like above)
Current Behavior
Any @provide(CLASSNAMEHERE) on my controllers simply leads to a unbound controller (route throws a 404)
Possible Solution
A temporary workaround is binding modules manually and them loading them on container.load.
For example:
export const assetControllerContainer = new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind) => {
bind<CreateAssetController>(CreateAssetController).toSelf();
bind<FilterAssetController>(FilterAssetController).toSelf();
bind<ReadAssetController>(ReadAssetController).toSelf();
});
then
container.load(
buildProviderModule(),
assetControllerContainer,
....
);
Yes. the controllers should be manually imported in your ioc
file. I know this is not ideal
PR's are welcomed to fix this