Recently, I've been diving into the world of typescript and working with express middlewares. One thing that has piqued my curiosity is determining the correct signatures for these middlewares. Typically, I have been defining my middlewares like this:
const middleware = async(req: Request, res: Response, next: NextFunction) => {
// Middleware logic goes here
if(condition)
next()
// Alternatively, I also use
return next()
}
I'm wondering if this approach is correct or if there is a best practice that I should be following. Additionally, what should be the return type of middlewares?