Comments (2)
hey @b1ff .
I saw that you've made a PR for this. but it's already possible to do this in inversify-express-utils
. Let me give you an example.
@injectable()
export class AuthorizationMiddleware extends BaseMiddleware {
@inject(TYPES.USER_REPOSITORY)
private readonly userRepository!: EntityRepository<User>;
constructor(
@inject(TYPES.USER_REPOSITORY)
private readonly userRepositoryFromConstructor: EntityRepository<User>
) {
super();
}
public handler(_req: Request, _res: Response, next: NextFunction): void {
console.log(this.userRepository);
console.log(this.userRepositoryFromConstructor);
next();
}
}
And then for the container binding
container.bind(AuthorizationMiddleware).toSelf();
Is this what you were looking for ?
from inversify-express-utils.
@PodaruDragos hey there, not really. The issue is when I do
this.bind(..).to...();
in middleware, I cannot inject it using constructor to middleware. I have to use httpContext.containter.get()
. While it works as workaround, it is better from testability and cleanness to inject it via middleware constructor, even if it was bound to container on httpContext.
You might see that behavior in test that I have added.
from inversify-express-utils.
Related Issues (20)
- Error trying to instantiate controller in a test (Error: No matching bindings found for serviceIdentifier: Symbol(HttpContext)) HOT 1
- inversify-express-utils, support of express 4.17.1 HOT 1
- [Inversify Express Utils] Controller is Reconstructed on Every Request HOT 1
- Inversify-Express-Untils Cannot Build Multiple Servers HOT 1
- Is inversify-express-utils no longer under maintenance? HOT 1
- integrating inversify-express-utils with inversify-socket-utils
- inversify-express-utils: BaseHttpController's conflict should take an argument
- [inversify-express-utils] AuthProvider Unhandled Promise Rejection HOT 1
- inversify-socket-io-utils - new project submission HOT 1
- Contextual injection not working with express utils decorators (inversify-express-utils) HOT 1
- [inversify-express-utils] Nesting controllers and maintaining route context HOT 2
- Passing additional data to Middleware HOT 2
- Handling singletons in creation of large plans HOT 3
- [inversify-express-utils]: Auth provider cannot rely on server-level middleware HOT 3
- [Feature Request] Add request, response, next to BaseHttpController
- Adding route config while creating server doesn't assign mount path to baseurl property of express request object
- JsonContent doesn't send correctly HOT 7
- Can not inject dependency in my CustomAuthProvider HOT 1
- Breaking changes from TypeScript update HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inversify-express-utils.