ti2 1.0.22 → 1.0.25
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/cache.js +11 -0
- package/controllers/user.js +15 -1
- package/package.json +1 -1
- package/worker/index.js +4 -1
package/cache.js
CHANGED
|
@@ -55,8 +55,19 @@ const getOrExec = async ({
|
|
|
55
55
|
return value;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
const drop = async ({
|
|
59
|
+
pluginName,
|
|
60
|
+
fn,
|
|
61
|
+
fnParams,
|
|
62
|
+
}) => {
|
|
63
|
+
let key = hash({ fn, fnParams });
|
|
64
|
+
key = `${pluginName}:${key}`;
|
|
65
|
+
await cache.del(key);
|
|
66
|
+
};
|
|
67
|
+
|
|
58
68
|
module.exports = {
|
|
59
69
|
cache,
|
|
60
70
|
save,
|
|
61
71
|
getOrExec,
|
|
72
|
+
drop,
|
|
62
73
|
};
|
package/controllers/user.js
CHANGED
|
@@ -14,11 +14,25 @@ const userAppList = async (req, res, next) => {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// source: https://stackoverflow.com/questions/31054910/get-functions-methods-of-a-class
|
|
18
|
+
const getAllFuncs = toCheck => {
|
|
19
|
+
const props = [];
|
|
20
|
+
let obj = toCheck;
|
|
21
|
+
do {
|
|
22
|
+
props.push(...Object.getOwnPropertyNames(obj));
|
|
23
|
+
} while (obj = Object.getPrototypeOf(obj));
|
|
24
|
+
|
|
25
|
+
return props.sort().filter((e, i, arr) => {
|
|
26
|
+
if (e !== arr[i + 1] && typeof toCheck[e] === 'function') return true;
|
|
27
|
+
return undefined;
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
17
31
|
const getAppMethods = plugins => async (req, res, next) => {
|
|
18
32
|
const { params: { appKey } } = req;
|
|
19
33
|
try {
|
|
20
34
|
const app = plugins.filter(({ name }) => name === appKey)[0];
|
|
21
|
-
const methods =
|
|
35
|
+
const methods = getAllFuncs(app);
|
|
22
36
|
return res.json({
|
|
23
37
|
methods,
|
|
24
38
|
});
|
package/package.json
CHANGED
package/worker/index.js
CHANGED
|
@@ -40,7 +40,10 @@ const worker = ({ plugins: pluginsParam }) => (id, disconnect) => {
|
|
|
40
40
|
return pluginsParam;
|
|
41
41
|
})();
|
|
42
42
|
const thePlugin = plugins.find(({ name }) => name === pluginName);
|
|
43
|
-
const resultValue = await thePlugin[method](
|
|
43
|
+
const resultValue = await thePlugin[method]({
|
|
44
|
+
...params,
|
|
45
|
+
plugins,
|
|
46
|
+
});
|
|
44
47
|
console.log(`job ${jobId} > completed`);
|
|
45
48
|
await saveResult({ id: jobId, resultValue });
|
|
46
49
|
});
|