Comments (7)
I believe an AfterMiddleware decorator would be a great feature.
It's great for use cases such as:
- Tracking the number of completed requests (for billing purposes for example).
- Logging.
- Disposing resources.
I believe it wouldn't be much work, I can make a PR for this.
from tsoa.
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.👀
from tsoa.
I assume you are using Express,
there is two way to archive such feature.
- custom template and make your own handler function,
register every route with after middleware by yourself,
details you can search on StackOverflow, I believe there is some example such asCall middleware after response sent in Express
- tsoa indeed can provides such feature by including an
AfterMiddleware
decorator.
but I doubt the necessity of it right now.
cc @WoH need your opinion.
from tsoa.
(req, res, next) => {
next()
console.log('post')
}
Should do it, right?
from tsoa.
(req, res, next) => { next() console.log('post') }Should do it, right?
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.
from tsoa.
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
from tsoa.
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?
from tsoa.
Related Issues (20)
- programmatic way to generate the spec and routes HOT 13
- Custom parameters in controller HOT 4
- Evaluate @Security in order of definition HOT 3
- AuthenticationMiddleware should also depend on authenticationModule being present HOT 2
- Unable to assign null to properties defined as number | null | undefined after updating to version 6.2.0 HOT 3
- Reasoning for always setting defaultNumberType HOT 2
- Can't send stream to injected error responder when using '@Security()` decorator. (Really I'm just trying to create a plain-text error) HOT 2
- Declare Auth schema without need to implement handlers HOT 2
- Make express request injectable HOT 3
- Problem with @types/express version 4.17.21 HOT 2
- Upload multiple files using @UploadedFiles() and @UploadedFile causes multer error HOT 2
- Using combination of @UploadedFile() and @UploadedFiles() decorators throws MulterError: Unexpected field HOT 3
- GenerateMetadataError: Unknown type: IndexedAccessType HOT 6
- GenerateMetadataError: Unknown type: IntrinsicKeyword HOT 3
- Routes.ts TSC Error expressAuthenticationRecasted HOT 1
- Multiple runtime dependencies for backend frameworks. HOT 1
- nullable: true and allOf HOT 1
- Support verbatimModuleSyntax (tsconfig) HOT 2
- Regression in route generation from 5.1.1 to 6.x.x: "This node kind is unknown"
- CLI cannot import tsoa-config.js in ESM project HOT 2
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 tsoa.