app.use()
app.use(express.json()) // this is assigned to ALL requests
what can be equivalent to
app.use(/*Only POST AND PUT*/,express.json()) // this is assigned to ALL requests
app.use(express.json()) // this is assigned to ALL requests
what can be equivalent to
app.use(/*Only POST AND PUT*/,express.json()) // this is assigned to ALL requests
express-conditional-middleware allows:
const conditional = require('express-conditional-middleware');
app.use(conditional(req => ['POST', 'PUT'].includes(req.method), express.json()));