-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-mock-config-example.js
44 lines (42 loc) · 1.56 KB
/
simple-mock-config-example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* simple-mock 配置信息
* @see {@link https://github.com/lzwme/simple-mock/blob/master/types/index.d.ts}
*/
/** @type {import('@lzwme/simple-mock').SimpleMockConfig} */
module.exports = {
mockFileDir: 'mock',
isEnableMock: false,
isAutoSaveApi: true,
isForceSaveApi: false,
// silent: false,
// logLevel: 'info',
// fnAutosaveFilter(content, filePath, req, res) {
// // 示例: 不保存 content.data.length = 0 的数据
// if (content && Array.isArray(content.data) && !content.data.length) {
// return false;
// }
// // 示例: 不强制保存 errorCode 不为 0 的错误类信息
// if (content && +content.errorCode > 0 && this.isForceSaveApi && require('fs').existsSync(filePath)) {
// return;
// }
// return true;
// },
// disableMockFilter: (apiPath, req) => {
// // 示例:按URL关键字过滤,不 mock 登陆 API
// // const filterKeyList = ['/rest/auth'];
// // const find = filterKeyList.find(path => String(apiPath).includes(path));
// // if (find) return true;
// return false;
// },
// enableMockFilter: (apiPath, req) => {
// // 示例:按URL关键字过滤
// // const filterKeyList = ['test'];
// // const find = filterKeyList.find(path => String(apiPath).includes(path));
// // if (find) return true;
// return false;
// },
// customSaveFileName: (req, res, filename, type) => filename,
// handlerBeforeMockSend: (content, req, res) => content,
// fnAutosavePerHandler: (content, mockFilePath, req, res) => content,
// } as SimpleMockConfig;
};