
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@zhike/log-express-middleware
Advanced tools
日志打印中间件

$ npm install @zhike/log-express-middleware
const logger = require('@zhike/log-express-middleware')
const Express = require('express')
var bodyParser = require('body-parser')
const app = new Express()
app.use(bodyParser.json())
//只打印requestBody
app.use(logger())
// 打印所有路径的headers中的content-type。只打印以/player2开头的路径的responseBody
app.use(logger({
requestHeaders: ['content-type'],
responseHeaders: ['content-type'],
responseBodyWhiteList: ['/^\/player2/']
}))
// 对密码进行隐藏
app.use(logger({
handler: function(req, res, _log) {
if (req.path === '/signin') {
_log.requestBody.password = '****1**'
}
}
}))
| 参数名 | 类型 | 说明 |
|---|---|---|
| reqId | String | 响应标识id(使用自定义的reqId需放在日志中间件前。如果为空且ctx.reqId为空则使用uuidv4自动生成reqId) |
| requestHeaders | Array | 需要打印的request头部 (默认不打印) |
| responseHeaders | Array | 需要打印的response头部 (默认不打印) |
| responseBodyWhiteList | Array | 白名单,字符串数组,可为正则(对于正则匹配剔除部分路由,可在业务代码中的ctx.useResponseBodyOption=false跳过路由规则) |
| responseBodyBlackList | Array | 黑名单,字符串数组,可为正则(对于正则匹配剔除部分路由,可在业务代码中使用ctx.useResponseBodyOption=false跳过路由规则) |
| handler | Function(req, res, _log) | 特殊处理函数。_log目前有requestBody属性,可以用来调整requestBody打印(是req.body的副本,进行修改,不会影响req.body) |
注意:
FAQs
We found that @zhike/log-express-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.