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
Middleware decorators #47
Comments
@Paldom I really like that idea. I'll get back to you with some more in-depth thoughts. |
@Paldom Custom route templates have been introduced recently; I think that offers enough to allow you to provide these customized middlewares. |
@lukeautry While custom route templates will work since they are highly customizable, I think the routes-template is a little tedious to maintain (IMHO). I'm currently using inversify-express-utils in my projects and they solved the issue using decorators, which I think is a little nicer and is discussed here: inversify/InversifyJS#487. @Controller("/")
@Middleware(Constants.AuthorizeMiddleware)
class MyController { Option 2 @Controller("/", Constants.AuthorizeMiddleware)
class MyController { Thoughts? |
@ezra-quemuel I really like your proposal, have you solved it in some way? may be it's possible to add this middleware decorator in easy way ? |
@lukeautry Has this functionality ever been implemented? As far as I know (which isn't much) there's no way to add additional custom metadata to controllers/methods making it really awkward and maintenance-heavy to implement this using custom templates. |
I'm looking into migrating out of inversifyjs into this library and typescript-ioc. |
Can we reopen this issue? I'm also having the same issue right now, even though I'm aware of the custom route templates, It would be way cleaner if I just coudl add "Middleware" like propsed earlier. I could work on this feature if this is a "valid" feature @lukeautry ? |
id like to do the |
Hello,
it would be great to have some kind of Middleware decorators, where you can give middlewares to run before (or even after) a controller method. Middlewares could be on a separate layer or even special controller methods.
e.g.
With this feature, existing Node.js projects would be much easeier to migrate into a tsoa project and also middleware pattern is essential part of Node.js applications.
It's could be an issue how to handle middleware chains, so e.g.
MiddlewareBefore
could contain an array of middlewares, or multiple decorators could be attached.If we discuss the details I can help with implementation.
Thanks!
The text was updated successfully, but these errors were encountered: