How to call check inside the middleware instead of passing as middleware
See original GitHub issueI already have middleware already, I don’t like to use check
as middlewares to this, is there anyway to use check
inside reqHandler
? Like how we used with Legacy API ?
const reqHandler = (req, res, next) => {
// do something
};
router.post('/createTask', reqHandler);
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to call a middleware function from inside ... - Stack Overflow
For this, I create a new middleware isLoggedIn . The problem here is that if I find the user is logged in, I...
Read more >Writing middleware for use in Express apps
The middleware function myLogger simply prints a message, then passes on the request to the next middleware function in the stack by calling...
Read more >How Node JS middleware Works? - Selvaganesh - Medium
Call the next middleware in the stack. If the current middleware function does not end the request-response cycle, it must call next() to...
Read more >How to pass variables to the next middleware using next() in ...
The following example covers how to pass variables to the next middleware using next() in Express.js. Approach: We cannot directly pass data ...
Read more >Build and Understand Express Middleware through Examples
In order to call an error-handling middleware, you simply pass the error to next() , like this: app.get('/my-other-thing' ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For a more intuitive solution regarding multiple checks, you could also attach your checks to a router and call that router inside your middleware/request handler.
Something like so:
I would think for one check something like this should work.