fix: controller rebind error

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-06-21 23:26:22 +08:00
parent b0c281c6f6
commit bcfab87860

View File

@ -38,8 +38,9 @@ function rebuildServer(container: Container) {
// get all controller
let controllers = container.getAll<express_interfaces.Controller>(TYPE.Controller)
// for loop controllers and inject proxy to each method
container.unbind(TYPE.Controller);
for (const controller of controllers) {
container.rebind(TYPE.Controller)
container.bind(TYPE.Controller)
.to(controller.constructor as any)
.inSingletonScope()
.whenTargetNamed(controller.constructor.name)