mm_options 1.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/example/index.js +6 -6
- package/index.js +4 -21
- package/lib/admin.js +36 -0
- package/lib/options.js +10 -6
- package/package.json +3 -3
- package/tool/option/index.js +67 -4
- package/tool/option_admin/index.js +36 -0
- package/tool/option_admin/tool.json +11 -0
- package/lib/tools/index.js +0 -16
- package/lib/tools/option/index.js +0 -70
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ npm install mm_options
|
|
|
29
29
|
## 快速开始
|
|
30
30
|
|
|
31
31
|
```javascript
|
|
32
|
-
const { Options,
|
|
32
|
+
const { Options, optionAdmin } = require('mm_options');
|
|
33
33
|
|
|
34
34
|
// 直接使用存储类
|
|
35
35
|
const options = new Options({ file: './data/options.json' });
|
|
@@ -38,7 +38,7 @@ options.set('theme', 'light'); // 覆盖
|
|
|
38
38
|
options.save();
|
|
39
39
|
|
|
40
40
|
// 通过管理器按作用域获取实例(相同作用域返回同一实例)
|
|
41
|
-
const scoped =
|
|
41
|
+
const scoped = optionAdmin('app', { file: './data/app_options.json' });
|
|
42
42
|
scoped.set('lang', 'zh');
|
|
43
43
|
|
|
44
44
|
// 配置修改密钥后,修改类操作必须传入正确密钥
|
|
@@ -79,7 +79,7 @@ const options = new Options(config);
|
|
|
79
79
|
|
|
80
80
|
| 函数 | 说明 | 参数 | 返回值 |
|
|
81
81
|
|---|---|---|---|
|
|
82
|
-
|
|
|
82
|
+
| optionAdmin | 获取指定作用域的动态配置实例,不存在时创建 | scope, config | Options |
|
|
83
83
|
| admin | 内部 Admin 管理器实例 | - | Admin |
|
|
84
84
|
|
|
85
85
|
## 使用示例
|
|
@@ -162,17 +162,17 @@ console.log(options.list()); // 获取副本
|
|
|
162
162
|
### 4. 作用域工厂
|
|
163
163
|
|
|
164
164
|
```javascript
|
|
165
|
-
const {
|
|
165
|
+
const { optionAdmin } = require('mm_options');
|
|
166
166
|
|
|
167
167
|
// 相同作用域返回同一实例
|
|
168
|
-
const app =
|
|
168
|
+
const app = optionAdmin('app', { file: './data/app_options.json', secret: 'app_secret' });
|
|
169
169
|
app.set('lang', 'zh', 'app_secret');
|
|
170
170
|
|
|
171
|
-
const appAgain =
|
|
171
|
+
const appAgain = optionAdmin('app');
|
|
172
172
|
console.log(appAgain === app); // true
|
|
173
173
|
|
|
174
174
|
// 缺省作用域为 os
|
|
175
|
-
const os_options =
|
|
175
|
+
const os_options = optionAdmin();
|
|
176
176
|
```
|
|
177
177
|
|
|
178
178
|
## 注意事项
|
|
@@ -182,7 +182,7 @@ const os_options = optionsAdmin();
|
|
|
182
182
|
3. 配置了 `secret` 后,`set` / `del` / `clear` / `save` 必须传入正确密钥,否则抛出 `密钥错误,无权修改配置`。
|
|
183
183
|
4. 未配置 `secret`(默认)时不校验密钥,旧有调用无需改动。
|
|
184
184
|
5. 密钥校验先于参数校验,密钥错误时优先抛出密钥异常。
|
|
185
|
-
6. `secret` 只在首次创建实例时生效;`
|
|
185
|
+
6. `secret` 只在首次创建实例时生效;`optionAdmin` 对相同作用域复用已有实例,后续传入的 `config` 不会覆盖。
|
|
186
186
|
7. 实例仅保存密钥的 SHA-256 摘要且不可逆,密钥遗失后无法从实例还原,只能重新创建实例。
|
|
187
187
|
8. 持久化文件只包含配置键值,不包含密钥或密钥摘要。
|
|
188
188
|
9. 密钥以 SHA-256 摘要比对,适用于防误改与权限隔离,不等同于加密存储,敏感配置请另行加密。
|
package/example/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* mm_options 动态配置存储示例
|
|
3
|
-
* 演示
|
|
3
|
+
* 演示 optionAdmin() 作用域工厂,以及 Options 类运行时
|
|
4
4
|
* 可修改的键值配置存取与 JSON 文件持久化(save / load)。
|
|
5
5
|
* 运行:node example/index.js
|
|
6
6
|
*/
|
|
7
7
|
const fs = require('fs');
|
|
8
8
|
const os = require('os');
|
|
9
9
|
const path = require('path');
|
|
10
|
-
const { Options,
|
|
10
|
+
const { Options, optionAdmin } = require('../index.js');
|
|
11
11
|
|
|
12
12
|
/** 示例临时目录 */
|
|
13
13
|
const TMP_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'mm-options-example-'));
|
|
@@ -17,13 +17,13 @@ const TMP_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'mm-options-example-'));
|
|
|
17
17
|
*/
|
|
18
18
|
function main() {
|
|
19
19
|
// 方式1:作用域工厂,获取 os 作用域的动态配置实例
|
|
20
|
-
|
|
20
|
+
let store = optionAdmin('os');
|
|
21
21
|
store.set('theme', 'dark');
|
|
22
22
|
console.log('工厂实例读取 theme:', store.get('theme'));
|
|
23
23
|
|
|
24
24
|
// 方式2:类实例 + 文件持久化
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let file = path.join(TMP_DIR, 'options.json');
|
|
26
|
+
let options = new Options({ file });
|
|
27
27
|
options.set('theme', 'dark').set('language', 'zh_cn');
|
|
28
28
|
console.log('配置列表:', options.list());
|
|
29
29
|
console.log('保存到文件:', options.save());
|
|
@@ -33,7 +33,7 @@ function main() {
|
|
|
33
33
|
console.log('动态修改后 theme:', options.get('theme'));
|
|
34
34
|
|
|
35
35
|
// 从文件重新加载(文件里是保存时的 dark)
|
|
36
|
-
|
|
36
|
+
let loaded = new Options({ file });
|
|
37
37
|
loaded.load();
|
|
38
38
|
console.log('重新加载后 theme:', loaded.get('theme'));
|
|
39
39
|
|
package/index.js
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
const { reg } = require('mm_admin');
|
|
2
2
|
const Options = require('./lib/options.js');
|
|
3
|
+
const { optionAdmin, getOptions } = require('./lib/admin.js');
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
let admin = reg('options');
|
|
5
6
|
admin.setClass(Options);
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
Options,
|
|
9
10
|
admin,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @param {string} [scope] 作用域名称,缺省时使用 os
|
|
13
|
-
* @param {{file?: string, secret?: string}} [config] 配置对象
|
|
14
|
-
* @returns {Options} 动态配置实例
|
|
15
|
-
*/
|
|
16
|
-
optionsAdmin(scope, config) {
|
|
17
|
-
return admin.get(scope || 'os', config);
|
|
18
|
-
},
|
|
19
|
-
/**
|
|
20
|
-
* 获取缺省动态配置实例
|
|
21
|
-
* @returns {Options} 动态配置实例
|
|
22
|
-
*/
|
|
23
|
-
getOptions() {
|
|
24
|
-
return admin.get('os');
|
|
25
|
-
}
|
|
11
|
+
optionAdmin,
|
|
12
|
+
getOptions
|
|
26
13
|
};
|
|
27
|
-
|
|
28
|
-
/* mm-tool-logic-export 工具能力层:其它模块可 require("mm_options").tools.<name> 直接引用 */
|
|
29
|
-
Object.defineProperty(module.exports, 'tools', { enumerable: true, configurable: true,
|
|
30
|
-
get: function () { return require('./lib/tools'); } });
|
package/lib/admin.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { reg } = require('mm_admin');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 动态配置实例管理(非类文件)
|
|
5
|
+
* optionAdmin / getOptions 获取 mm_admin 'options' 注册池中的动态配置实例。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 获取指定作用域的动态配置实例,不存在时创建
|
|
10
|
+
* @param {string} [scope] 作用域名称,缺省时使用 os
|
|
11
|
+
* @param {{file?: string, secret?: string}} [config] 配置对象
|
|
12
|
+
* @returns {object} 动态配置实例
|
|
13
|
+
*/
|
|
14
|
+
function optionAdmin(scope, config) {
|
|
15
|
+
let admin = reg('options');
|
|
16
|
+
let name = scope || 'os';
|
|
17
|
+
let existed = admin.has(name);
|
|
18
|
+
let options = admin.get(name, config);
|
|
19
|
+
if (!existed) {
|
|
20
|
+
options.restore();
|
|
21
|
+
}
|
|
22
|
+
return options;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 获取缺省动态配置实例
|
|
27
|
+
* @returns {object} 动态配置实例
|
|
28
|
+
*/
|
|
29
|
+
function getOptions() {
|
|
30
|
+
return reg('options').get('os');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
optionAdmin,
|
|
35
|
+
getOptions
|
|
36
|
+
};
|
package/lib/options.js
CHANGED
|
@@ -8,7 +8,7 @@ const KvStore = require('mm_kv_store').KvStore;
|
|
|
8
8
|
*/
|
|
9
9
|
function _hashSecret(secret) {
|
|
10
10
|
if (typeof secret !== 'string' || secret.length === 0) {
|
|
11
|
-
return
|
|
11
|
+
return null;
|
|
12
12
|
}
|
|
13
13
|
return crypto.createHash('sha256').update(secret).digest('hex');
|
|
14
14
|
}
|
|
@@ -31,18 +31,22 @@ class Options extends KvStore {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @type {string}
|
|
34
|
+
* 密钥摘要,null 表示未配置密钥
|
|
35
|
+
* @type {string|null}
|
|
36
36
|
*/
|
|
37
|
-
#secret_hash =
|
|
37
|
+
#secret_hash = null;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* 构造函数
|
|
41
41
|
* @param {{file?: string, secret?: string}} [config] 配置对象
|
|
42
42
|
*/
|
|
43
43
|
constructor(config = {}) {
|
|
44
|
-
|
|
44
|
+
let { secret, ...rest_config } = { ...Options.config, ...config };
|
|
45
|
+
if (secret !== undefined && secret !== null && typeof secret !== 'string') {
|
|
46
|
+
throw new TypeError('secret 必须是字符串');
|
|
47
|
+
}
|
|
45
48
|
super(rest_config);
|
|
49
|
+
// 空串密钥视为未配置(与缺省一致),内部以 null 为"无密钥"哨兵
|
|
46
50
|
this.#secret_hash = _hashSecret(secret);
|
|
47
51
|
}
|
|
48
52
|
|
|
@@ -53,7 +57,7 @@ class Options extends KvStore {
|
|
|
53
57
|
* @throws {Error} 已配置密钥且传入密钥不一致时抛出
|
|
54
58
|
*/
|
|
55
59
|
_checkSecret(secret) {
|
|
56
|
-
if (
|
|
60
|
+
if (this.#secret_hash === null) {
|
|
57
61
|
return;
|
|
58
62
|
}
|
|
59
63
|
if (_hashSecret(secret) !== this.#secret_hash) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_options",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "动态配置存储模块:适用于站长/用户配置,可在运行时动态修改",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"配置",
|
|
16
16
|
"存储"
|
|
17
17
|
],
|
|
18
|
-
"layer": "
|
|
19
|
-
"group": "
|
|
18
|
+
"layer": "store",
|
|
19
|
+
"group": "data",
|
|
20
20
|
"author": "邱文武",
|
|
21
21
|
"license": "ISC",
|
|
22
22
|
"scripts": {
|
package/tool/option/index.js
CHANGED
|
@@ -1,7 +1,70 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* option ——
|
|
4
|
-
*
|
|
5
|
-
* 其它模块可直接 require('mm_options').tools.option 复用。
|
|
3
|
+
* option —— 动态配置存取工具
|
|
4
|
+
* 复用模块 Options 实例的读写与落盘能力。
|
|
6
5
|
*/
|
|
7
|
-
|
|
6
|
+
const { optionAdmin } = require('../../index.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 落盘:未配置持久化文件时只保留内存结果
|
|
10
|
+
* @param {object} store 存储实例
|
|
11
|
+
* @returns {boolean} 是否已落盘
|
|
12
|
+
*/
|
|
13
|
+
function _save(store) {
|
|
14
|
+
let file = (store.config && store.config.file) || '';
|
|
15
|
+
if (!file) return false;
|
|
16
|
+
store.save();
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function main(params, ctx, options) {
|
|
21
|
+
void options;
|
|
22
|
+
let p = params || {};
|
|
23
|
+
let action = p.action || 'list';
|
|
24
|
+
const done = (data) => { ctx.output = data; return data; };
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
let store = optionAdmin(p.scope || 'os');
|
|
28
|
+
|
|
29
|
+
if (action === 'set') {
|
|
30
|
+
if (!p.key) throw new TypeError('key 不能为空');
|
|
31
|
+
store.set(p.key, p.value);
|
|
32
|
+
_save(store);
|
|
33
|
+
return done({ code: 0, msg: '写入成功', key: p.key });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (action === 'get') {
|
|
37
|
+
if (!p.key) throw new TypeError('key 不能为空');
|
|
38
|
+
return done({ code: 0, msg: '成功', key: p.key, value: store.get(p.key), exists: store.has(p.key) });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (action === 'del') {
|
|
42
|
+
if (!p.key) throw new TypeError('key 不能为空');
|
|
43
|
+
let deleted = store.del(p.key);
|
|
44
|
+
_save(store);
|
|
45
|
+
return done({ code: 0, msg: deleted ? '删除成功' : '配置不存在', key: p.key, deleted: !!deleted });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (action === 'list') {
|
|
49
|
+
let list = store.list();
|
|
50
|
+
return done({ code: 0, msg: '成功', list, count: Object.keys(list || {}).length });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (action === 'clear') {
|
|
54
|
+
store.clear();
|
|
55
|
+
_save(store);
|
|
56
|
+
return done({ code: 0, msg: '已清空' });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (action === 'save') {
|
|
60
|
+
_save(store);
|
|
61
|
+
return done({ code: 0, msg: '已落盘', ok: true });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return done({ code: 10001, msg: '不支持的操作: ' + action });
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return done({ code: 10000, msg: '执行失败:' + error.message, error: { name: error.name, message: error.message } });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = { main };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { admin } = require('../../index.js');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 管理选项存储实例池
|
|
6
|
+
* @param {object} params 参数:action/scope
|
|
7
|
+
* @param {object} ctx 执行上下文
|
|
8
|
+
* @returns {Promise<object>} 执行结果
|
|
9
|
+
*/
|
|
10
|
+
async function main(params, ctx) {
|
|
11
|
+
let p = params || {};
|
|
12
|
+
let action = p.action || 'list';
|
|
13
|
+
let scope = p.scope || 'os';
|
|
14
|
+
const done = (data) => {
|
|
15
|
+
if (ctx) ctx.output = data;
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
try {
|
|
19
|
+
if (action === 'list') {
|
|
20
|
+
let scopes = [...admin.keys()];
|
|
21
|
+
return done({ code: 0, msg: '获取成功', action, count: scopes.length, scopes });
|
|
22
|
+
}
|
|
23
|
+
if (action === 'inspect') {
|
|
24
|
+
let exists = admin.has(scope);
|
|
25
|
+
let instance = exists ? admin.get(scope) : null;
|
|
26
|
+
return done({ code: 0, msg: exists ? '获取成功' : '实例不存在', action, scope, exists, config: instance && instance.config ? instance.config : null });
|
|
27
|
+
}
|
|
28
|
+
if (action === 'del') return done({ code: 0, msg: '删除成功', action, scope, ok: admin.del(scope) });
|
|
29
|
+
if (action === 'clear') { admin.clear(); return done({ code: 0, msg: '实例池已清空', action }); }
|
|
30
|
+
return done({ code: 10001, msg: '不支持的操作: ' + action });
|
|
31
|
+
} catch (error) {
|
|
32
|
+
return done({ code: 10000, msg: '执行失败:' + error.message, error: { name: error.name, message: error.message } });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = { main };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "option_admin",
|
|
3
|
+
"title": "选项存储实例管理",
|
|
4
|
+
"description": "管理 mm_options 的实例池:list 列出实例、inspect 查看配置、del 删除实例、clear 清空实例池。",
|
|
5
|
+
"category": "选项存储",
|
|
6
|
+
"group": "state",
|
|
7
|
+
"type": "function",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"params": { "type": "object", "properties": { "action": { "type": "string", "description": "操作类型: list/inspect/del/clear", "default": "list" }, "scope": { "type": "string", "description": "实例作用域,缺省 os", "default": "os" } }, "required": ["action"] },
|
|
10
|
+
"handler": "manager"
|
|
11
|
+
}
|
package/lib/tools/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
/** 模块能力层:懒加载工具实现,避免模块入口被 require 时加载全部实现 */
|
|
5
|
-
module.exports = new Proxy({}, {
|
|
6
|
-
get(_t, key) {
|
|
7
|
-
if (typeof key !== 'string') return undefined;
|
|
8
|
-
if (!fs.existsSync(path.join(__dirname, key, 'index.js'))) return undefined;
|
|
9
|
-
return require('./' + key);
|
|
10
|
-
},
|
|
11
|
-
has(_t, key) {
|
|
12
|
-
return typeof key === 'string' && fs.existsSync(path.join(__dirname, key, 'index.js'));
|
|
13
|
-
},
|
|
14
|
-
ownKeys() { return fs.readdirSync(__dirname, { withFileTypes: true }).filter(e => e.isDirectory()).map(e => e.name); },
|
|
15
|
-
getOwnPropertyDescriptor(_t, key) { return this.has(_t, key) ? { enumerable: true, configurable: true } : undefined; }
|
|
16
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* option —— 动态配置存取工具
|
|
4
|
-
* 复用模块 Options 实例的读写与落盘能力。
|
|
5
|
-
*/
|
|
6
|
-
const { optionsAdmin } = require('../../../index.js');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 落盘:未配置持久化文件时只保留内存结果
|
|
10
|
-
* @param {object} store 存储实例
|
|
11
|
-
* @returns {boolean} 是否已落盘
|
|
12
|
-
*/
|
|
13
|
-
function _save(store) {
|
|
14
|
-
const file = (store.config && store.config.file) || '';
|
|
15
|
-
if (!file) return false;
|
|
16
|
-
store.save();
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async function main(params, ctx, options) {
|
|
21
|
-
void options;
|
|
22
|
-
const p = params || {};
|
|
23
|
-
const action = p.action || 'list';
|
|
24
|
-
const done = (data) => { ctx.output = data; return data; };
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
const store = optionsAdmin(p.scope || 'os');
|
|
28
|
-
|
|
29
|
-
if (action === 'set') {
|
|
30
|
-
if (!p.key) throw new TypeError('key 不能为空');
|
|
31
|
-
store.set(p.key, p.value);
|
|
32
|
-
_save(store);
|
|
33
|
-
return done({ code: 0, msg: '写入成功', key: p.key });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (action === 'get') {
|
|
37
|
-
if (!p.key) throw new TypeError('key 不能为空');
|
|
38
|
-
return done({ code: 0, msg: '成功', key: p.key, value: store.get(p.key), exists: store.has(p.key) });
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (action === 'del') {
|
|
42
|
-
if (!p.key) throw new TypeError('key 不能为空');
|
|
43
|
-
const deleted = store.del(p.key);
|
|
44
|
-
_save(store);
|
|
45
|
-
return done({ code: 0, msg: deleted ? '删除成功' : '配置不存在', key: p.key, deleted: !!deleted });
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (action === 'list') {
|
|
49
|
-
const list = store.list();
|
|
50
|
-
return done({ code: 0, msg: '成功', list, count: Object.keys(list || {}).length });
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (action === 'clear') {
|
|
54
|
-
store.clear();
|
|
55
|
-
_save(store);
|
|
56
|
-
return done({ code: 0, msg: '已清空' });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (action === 'save') {
|
|
60
|
-
_save(store);
|
|
61
|
-
return done({ code: 0, msg: '已落盘', ok: true });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return done({ code: 10001, msg: '不支持的操作: ' + action });
|
|
65
|
-
} catch (error) {
|
|
66
|
-
return done({ code: 10000, msg: '执行失败:' + error.message, error: { name: error.name, message: error.message } });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
module.exports = { main };
|