Question about express middleware. Say I have a route like the following:
router.route('/replies/:board')
.post(bodyThreadIdVal, textVal, passVal, replyHandler.postReply)
Now let's say I wanted to move the first three middleware arguments from above out of the post method and into a custom method I created in another file, named postReply. How would I go about doing this? I thought maybe using app.use within my postReply method but not sure exactly how or if there is a cleaner way.
I have tried a few methods including
this.postReply = async (req, res, next) => {
app.use(bodyThreadIdVal, textVal, passVal)(req, res, next)
/* additional code */
}
But this seems to cause a recursive loop that rejects with Maximum call stack size exceeded