-
Notifications
You must be signed in to change notification settings - Fork 508
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 after response #1593
Comments
Hello there SwagiWagi 👋 Thank you for opening your very first issue in this project. We will try to get back to you as soon as we can.👀 |
I assume you are using Express,
cc @WoH need your opinion. |
(req, res, next) => {
next()
console.log('post')
} Should do it, right? |
I believe an AfterMiddleware decorator would be a great feature.
I believe it wouldn't be much work, I can make a PR for this. |
tsoa/packages/cli/src/routeGeneration/templates/express.hbs Lines 92 to 116 in efdb468
Yes, just call next() in custom template, after L106 would work with after middleware. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
Sorry to bring up a dead issue. But this doesn't appear to have been implemented. I'm happy to do the PR if needed, or maybe there is discussion elsewhere as to why this wasn't added? |
add next() to express template, closes #1593
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
Have the ability to have middlewares of specific routes be called after response has been sent
Current Behavior
Possible Solution
Steps to Reproduce
@route("user")
export class UserController extends Controller {
@middlewares(validateUserId)
@get("{userId}")
async getUser(@path() userId: string) {
this.setStatus(200);
return {userId: userId};
}
}
Now I want a logging middleware to be called (for example), specifically after the response has been sent.
Context (Environment)
Version of the library: 6.1.5
Version of NodeJS: 20.11.0
Detailed Description
Breaking change?
The text was updated successfully, but these errors were encountered: