Create structured, declarative and beautifully organized class-based controllers with heavy decorators usage in Express / Koa using TypeScript and Routing Controllers Framework.
MIT License
4.41k
stars
394
forks
source link
fix: The current version of routing-controllers(0.9.0) is incompatible with the latest version of typedi(0.10.0) #896
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>'
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
Expected behavior
No error occurred.
Actual behavior