Middleware

Last Updated: March 17, 2021
const routes = (app) => {
    app.route('/contact')
        .get((req, res, next) => {
                console.log(`Request type: ${req.method}`)
                next()
            }, (req, res, next) => {
                res.send('GET is ok')
            }
        )
        .post((req, res) =>
            res.send('POST is ok')
}

export default routes;

Before the request is completed you can execute some code, we have used the next()