typestack / typeorm-typedi-extensions

Dependency injection and service container integration with TypeORM using TypeDI library.
MIT License
262 stars 37 forks source link

feature: support request scoped decorators (use container instance provided by TypeDI) #35

Closed mailaneel closed 3 years ago

mailaneel commented 5 years ago

Problem: Cannot use request scoped container instance

Decorators are currently using global container instead of passed container instance to value in registerHandler https://github.com/typeorm/typeorm-typedi-extensions/blob/5016faf3d99dfbfcbcad2395f4bce2628d1f31f1/src/decorators/InjectConnection.ts#L9

Why:

Allows more use cases where request scope(TypeDI) is required

Solution:

  Container.registerHandler({
    object,
    index,
    propertyName,
    value: containerInstance => {
      const connectionManager = containerInstance.get(ConnectionManager);
      return connectionManager.get(connectionName);
    },
  });
seawatts commented 4 years ago

Any progress on this?

NoNameProvided commented 3 years ago

Added in 3f13dc7f0bd9fa58c04499760257371dad32292d. Will be part of 0.4.0 release.

github-actions[bot] commented 3 years ago

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.