@zzxuan/zzx-mock
v1.0.2
Published
一个 mock 服务小工具
Downloads
1
Readme
zzx-mock
一个 mock 服务小工具
使用方法
// mock/user.js
const { mock } = require('mockjs')
module.exports = {
'GET /api/user': (req, res) => {
res.send(
mock({
username: '@string(6,12)',
})
)
},
}
添加自定义响应头
在 package.json
里添加属性 zzx-mock
,如下:
"zzx-mock": {
"responseHeader": {
"Access-Control-Allow-Headers": "content-type,authorization,others-zzx-in-request-header",
"Access-Control-Expose-Headers": "zzx-in-response-header-need-to-tell-frontend"
}
}
忽略特殊文件
例如,zzx-mock -i **/mock/**/*.generated.js
将忽略所有 *.generated.js
文件,添加忽略文件如下配置
"zzx-mock": {
"ignored": [
"**/mock/**/*.generated.js",
"**/mock/swagger.json"
]
},