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

fix: The current version of routing-controllers(0.9.0) is incompatible with the latest version of typedi(0.10.0) #896

Open
Comdex opened this issue Jun 17, 2022 · 1 comment
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.

Comments

@Comdex
Copy link

Comdex commented Jun 17, 2022

Description

The current version of routing-controllers(0.9.0) is incompatible with the latest version of typedi(0.10.0). When the two are integrated together, an error will be thrown, but there will be no problem using typedi version 0.8.0.
os: win10
node version: v16.13.0
ts version: 4.6.4

Minimal code-snippet showcasing the problem

import { createExpressServer, useContainer } from 'routing-controllers';
import { Container } from 'typedi';
import path from 'path';

useContainer(Container);

// create and run server
createExpressServer({
  controllers: [path.join(__dirname, '/controllers/*.js')],
  middlewares: [path.join(__dirname, '/middlewares/*.js')],
  interceptors: [path.join(__dirname, '/interceptors/*.js')],
}).listen(3000);

Expected behavior

No error occurred.

Actual behavior

[dev:*start] ServiceNotFoundError: Service with "MaybeConstructable<LoggerMiddleware>" identifier was not found in the container. Register it before usage via explicitly calling the
"Container.set" function or using the "@Service()" decorator.
[dev:*start]     at ContainerInstance.get (D:\tswork\test\node_modules\typedi\cjs\container-instance.class.js:45:15)
[dev:*start]     at Function.get (D:\tswork\test\node_modules\typedi\cjs\container.class.js:28:36)
[dev:*start]     at Object.getFromContainer (D:\tswork\test\node_modules\routing-controllers\cjs\container.js:39:44)
[dev:*start]     at MiddlewareMetadata.get instance [as instance] (D:\tswork\test\node_modules\routing-controllers\cjs\metadata\MiddlewareMetadata.js:25:28)
[dev:*start]     at ExpressDriver.registerMiddleware (D:\tswork\test\node_modules\routing-controllers\cjs\driver\express\ExpressDriver.js:53:24)
[dev:*start]     at D:\tswork\test\node_modules\routing-controllers\cjs\RoutingControllers.js:75:48
[dev:*start]     at Array.forEach (<anonymous>)
[dev:*start]     at RoutingControllers.registerMiddlewares (D:\tswork\test\node_modules\routing-controllers\cjs\RoutingControllers.js:75:14)
[dev:*start]     at createExecutor (D:\tswork\test\node_modules\routing-controllers\cjs\index.js:214:10)
[dev:*start]     at createServer (D:\tswork\test\node_modules\routing-controllers\cjs\index.js:146:5) {
[dev:*start]   normalizedIdentifier: 'MaybeConstructable<LoggerMiddleware>'
@Comdex Comdex added status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature. labels Jun 17, 2022
@shenggaowei
Copy link

I had the same problem

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.
Development

No branches or pull requests

2 participants