@x-9lab/xlab 1.5.2 → 1.5.3
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.
|
@@ -12,7 +12,6 @@ _export(exports, {
|
|
|
12
12
|
on: ()=>on,
|
|
13
13
|
kill: ()=>kill
|
|
14
14
|
});
|
|
15
|
-
const _common = require("../common");
|
|
16
15
|
const _utils = require("@x-drive/utils");
|
|
17
16
|
const _util = require("util");
|
|
18
17
|
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
@@ -55,7 +54,11 @@ const config = getSysConfig("cron") || {
|
|
|
55
54
|
if (!dont) {
|
|
56
55
|
JOB_STATUS[name] = true;
|
|
57
56
|
try {
|
|
58
|
-
|
|
57
|
+
if ((0, _utils.isExecutable)(mod)) {
|
|
58
|
+
mod();
|
|
59
|
+
} else if (mod.default && (0, _utils.isExecutable)(mod.default())) {
|
|
60
|
+
mod.default();
|
|
61
|
+
}
|
|
59
62
|
} catch (e) {
|
|
60
63
|
logger.error((0, _util.inspect)(e));
|
|
61
64
|
}
|
|
@@ -103,8 +106,8 @@ const config = getSysConfig("cron") || {
|
|
|
103
106
|
var stats = _fs.default.statSync(tmpPath);
|
|
104
107
|
if (stats.isFile()) {
|
|
105
108
|
var name = cron.replace(".js", "");
|
|
106
|
-
CRON_TIMERS[name] = fetch(
|
|
107
|
-
logger.info("
|
|
109
|
+
CRON_TIMERS[name] = fetch(require(_path.default.resolve(tmpPath)), name);
|
|
110
|
+
logger.info("[ %s ] %s.", name, CRON_TIMERS[name] ? "running" : "disabled");
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
}
|
package/dist/router.js
CHANGED
|
@@ -91,28 +91,31 @@ function _interopRequireDefault(obj) {
|
|
|
91
91
|
api = buildApi(api.join("/"));
|
|
92
92
|
}
|
|
93
93
|
// 是对象则取对应的字段
|
|
94
|
-
if ((0, _utils.isObject)(mod)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
apiPart.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
mod
|
|
115
|
-
|
|
94
|
+
if ((0, _utils.isObject)(mod)) {
|
|
95
|
+
const subjectMod = mod;
|
|
96
|
+
if ((0, _utils.isFunction)(subjectMod.handler) || (0, _utils.isAsyncFunction)(subjectMod.handler)) {
|
|
97
|
+
modName = subjectMod.method || "get";
|
|
98
|
+
api = subjectMod.api || api;
|
|
99
|
+
apiPart = api.split("/");
|
|
100
|
+
if (apiPart[0] !== "") {
|
|
101
|
+
apiPart.unshift("");
|
|
102
|
+
}
|
|
103
|
+
// 如果没有声明忽略检测则保证接口一定是以 api 开头的
|
|
104
|
+
if (!subjectMod.ignoreApiNameCheck && !IS_API_REGEXP.test(api)) {
|
|
105
|
+
api = buildApi(api);
|
|
106
|
+
}
|
|
107
|
+
if ((0, _utils.isArray)(subjectMod.middleware)) {
|
|
108
|
+
mod = [
|
|
109
|
+
api,
|
|
110
|
+
...subjectMod.middleware,
|
|
111
|
+
subjectMod.handler
|
|
112
|
+
];
|
|
113
|
+
} else {
|
|
114
|
+
mod = [
|
|
115
|
+
api,
|
|
116
|
+
subjectMod.handler
|
|
117
|
+
];
|
|
118
|
+
}
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
var dirMws = [];
|