Connect or Express middleware to modify the response.body

前端 未结 5 1541
一个人的身影
一个人的身影 2020-12-03 02:21

I would like to have a middleware function which modifies the response body.

This is for an express server.

Something like:

function modify(         


        
5条回答
  •  难免孤独
    2020-12-03 03:16

    express-mung is designed for this. Instead of events its just more middleware. Your example would look something like

    const mung = require('express-mung')
    
    module.exports = mung.json(body => body.modifiedBy = 'me');
    

提交回复
热议问题