q-koa 12.4.2 → 12.4.4
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/core/app.js
CHANGED
|
@@ -50,6 +50,11 @@ const starter = new EventEmitter()
|
|
|
50
50
|
|
|
51
51
|
const formatPostFunction = (str) => `eval(${str})`
|
|
52
52
|
|
|
53
|
+
const runVm = (_str) => {
|
|
54
|
+
return nodeVm.runInNewContext(_str)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const memRunVm = _.memoize(runVm)
|
|
53
58
|
const connectDatabase = (database) => (config) => {
|
|
54
59
|
if (!database) throw new Error('请配置数据库名称')
|
|
55
60
|
if (!config.username) throw new Error('请配置数据库账号')
|
|
@@ -1001,11 +1006,11 @@ class APP {
|
|
|
1001
1006
|
* 如果像user_distribute里有两个user,需要用这个来重新建立关系
|
|
1002
1007
|
*/
|
|
1003
1008
|
const _str = formatPostFunction(relate)
|
|
1004
|
-
|
|
1009
|
+
memRunVm(_str)(app[appName])
|
|
1005
1010
|
// relate.toFunction()(app[appName]);
|
|
1006
1011
|
}
|
|
1007
1012
|
const _str = formatPostFunction(include)
|
|
1008
|
-
const postInclude =
|
|
1013
|
+
const postInclude = memRunVm(_str)
|
|
1009
1014
|
const strInclude = postInclude(app[appName])
|
|
1010
1015
|
// const postInclude = include.toFunction();
|
|
1011
1016
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { lodash } = require('q-koa')
|
|
1
|
+
const { lodash, getConfig } = require('q-koa')
|
|
2
2
|
const axios = require('axios')
|
|
3
3
|
|
|
4
4
|
const is_dev = process.env.NODE_ENV !== 'production'
|
|
@@ -10,9 +10,31 @@ exports.push = async ({ app, appName = '通知', url, message }) => {
|
|
|
10
10
|
'https://api.day.app/ieaRfoE3LiPveGbY5qmUwk'
|
|
11
11
|
)
|
|
12
12
|
if (log_push_url) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const appConfig = getConfig(app)
|
|
14
|
+
const { site_name, logo_image, logo_img } = await appConfig.getObject(
|
|
15
|
+
'base'
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const queryObject = {
|
|
19
|
+
...(is_dev ? {} : { url: encodeURIComponent(url) }),
|
|
20
|
+
...(logo_image || logo_img
|
|
21
|
+
? {
|
|
22
|
+
icon: encodeURIComponent(
|
|
23
|
+
(logo_image || logo_img).replace('http', 'https')
|
|
24
|
+
),
|
|
25
|
+
}
|
|
26
|
+
: {}),
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const query = Object.keys(queryObject)
|
|
30
|
+
.map((key) => {
|
|
31
|
+
return `${key}=${queryObject[key]}`
|
|
32
|
+
})
|
|
33
|
+
.join('&')
|
|
34
|
+
|
|
35
|
+
const logUrl = `${log_push_url}/${encodeURIComponent(
|
|
36
|
+
site_name || appName
|
|
37
|
+
)}/${encodeURIComponent(message)}${query ? '?' + query : ''}`
|
|
16
38
|
|
|
17
39
|
axios({
|
|
18
40
|
url: logUrl,
|
|
@@ -2,6 +2,11 @@ const { getConfig, lodash, Sequelize } = require('q-koa')
|
|
|
2
2
|
const formatPostFunction = (str) => `eval(${str})`
|
|
3
3
|
const nodeVm = require('vm')
|
|
4
4
|
const axios = require('axios')
|
|
5
|
+
const runVm = (_str) => {
|
|
6
|
+
return nodeVm.runInNewContext(_str)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const memRunVm = lodash.memoize(runVm)
|
|
5
10
|
|
|
6
11
|
exports.initData = async ({ includes, excludes, app, ctx }) => {
|
|
7
12
|
const appConfig = getConfig(app)
|
|
@@ -86,7 +91,7 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
|
|
|
86
91
|
|
|
87
92
|
if (include) {
|
|
88
93
|
const _str = formatPostFunction(include)
|
|
89
|
-
const postInclude =
|
|
94
|
+
const postInclude = memRunVm(_str)
|
|
90
95
|
// const postInclude = include.toFunction();
|
|
91
96
|
if (!Array.isArray(postInclude(app))) {
|
|
92
97
|
if (process.env.NODE_ENV !== 'production') {
|