Skip to content

[inversify-express-utils] - No support for @controller on inevrfisy-binding-decorators? #359

Open
@jonit-dev

Description

@jonit-dev

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,
  ....
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions