Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support for awilix DI #656

Closed
sujansaresta opened this issue Feb 10, 2021 · 5 comments
Closed

feature: support for awilix DI #656

sujansaresta opened this issue Feb 10, 2021 · 5 comments
Labels
status: invalid Issues with no action to take. type: feature Issues related to new features.

Comments

@sujansaresta
Copy link

Description

I do not see any support for awilix for dependency Injection.

@sujansaresta sujansaresta added flag: needs discussion Issues which needs discussion before implementation. type: feature Issues related to new features. labels Feb 10, 2021
@warapitiya
Copy link

warapitiya commented Feb 19, 2021

I think probably not only awilix, but all other DIs. Like TSyringe.

Basically DI indipentant.

@thanipro
Copy link

thanipro commented Oct 9, 2021

I just found this package and this is how I am using it with TSyringe


import { ClassConstructor, IocAdapter } from 'routing-controllers';
import { DependencyContainer } from 'tsyringe';

class TsyringeAdapter implements IocAdapter {
  // eslint-disable-next-line no-unused-vars,no-useless-constructor,no-empty-function
  constructor(private readonly TsyringeContainer: DependencyContainer) {}

  get<T>(someClass: ClassConstructor<T>): T {
    const childContainer = this.TsyringeContainer.createChildContainer();
    return childContainer.resolve<T>(someClass);
  }
}

export default TsyringeAdapter;

And then in app.ts/index.ts

useContainer(new TsyringeAdapter(container));

@attilaorosz
Copy link
Member

You are free to use whatever DI lib you want as long as it complies with the typedi contracts, just as @thanipro showed. @NoNameProvided I think since the package provides the IocAdapter interface, we can close this.

@NoNameProvided
Copy link
Member

Yes, as all above me said, currently routing-controllers don't depend on any specific typedi functionality. You can use any other lib with the useContainer helper.

In the future, we may use stricter integration which may disallow some other packages, but currently, we don't.

@NoNameProvided NoNameProvided added status: invalid Issues with no action to take. type: feature Issues related to new features. and removed type: feature Issues related to new features. flag: needs discussion Issues which needs discussion before implementation. labels Feb 17, 2022
@NoNameProvided NoNameProvided changed the title support for awilix DI feature: support for awilix DI Feb 17, 2022
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: invalid Issues with no action to take. type: feature Issues related to new features.
Development

No branches or pull requests

5 participants