q-koa 10.1.4 → 10.2.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/core/app.js +2 -1
- package/core/file/plugins/weixin/service.js +5 -4
- package/core/file/utils/index.js +3 -3
- package/core/validator.js +12 -5
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -266,6 +266,7 @@ class APP {
|
|
|
266
266
|
|
|
267
267
|
starter.on('loadAll', async () => {
|
|
268
268
|
const appName = this.config.includes[0]
|
|
269
|
+
if (!this.app[appName]) throw new Error(`没有生成应用${this.config.includes[0]},请检查config includes`)
|
|
269
270
|
this.server = this.app.listen(this.port, () => {
|
|
270
271
|
console.log(
|
|
271
272
|
`${moment().format(
|
|
@@ -996,7 +997,7 @@ class APP {
|
|
|
996
997
|
|
|
997
998
|
if (!Array.isArray(strInclude))
|
|
998
999
|
throw new Error(`可能include不是一个数组`)
|
|
999
|
-
|
|
1000
|
+
|
|
1000
1001
|
myInclude =
|
|
1001
1002
|
app[appName] &&
|
|
1002
1003
|
app[appName].include &&
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { getAppByCtx, getConfig, lodash } = require('q-koa')
|
|
1
|
+
const { getAppByCtx, getAppConfig, getConfig, lodash } = require('q-koa')
|
|
2
2
|
const { Pay } = require('@sigodenjs/wechatpay')
|
|
3
3
|
const path = require('path')
|
|
4
4
|
const fsPromise = require('fs/promises')
|
|
@@ -174,9 +174,10 @@ exports.cash = async ({
|
|
|
174
174
|
if (!user) throw new Error('找不到该用户')
|
|
175
175
|
if (!user.mp_user.openid) throw new Error('找不到该用户openid')
|
|
176
176
|
|
|
177
|
-
const { mchId, key, appId, partner_key } = await
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
const { mchId, key, appId, partner_key } = await getAppConfig({
|
|
178
|
+
app,
|
|
179
|
+
app_id: user.mp_user.appid,
|
|
180
|
+
})
|
|
180
181
|
|
|
181
182
|
const { is_dev } = await appConfig.getObject('base')
|
|
182
183
|
|
package/core/file/utils/index.js
CHANGED
|
@@ -160,12 +160,12 @@ exports.getImageType = (fileBuffer) => {
|
|
|
160
160
|
return ''
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
exports.getAppConfig = async ({ app, config, key }) => {
|
|
164
|
-
if (!(app && (config || key))) return null
|
|
163
|
+
exports.getAppConfig = async ({ app, config, key, app_id }) => {
|
|
164
|
+
if (!(app && (config || key || app_id))) return null
|
|
165
165
|
const application =
|
|
166
166
|
app.cache.get('application') || (await app.model.application.findAll())
|
|
167
167
|
|
|
168
|
-
const target = application.find(findConfig(config || key))
|
|
168
|
+
const target = application.find(findConfig(config || key || app_id))
|
|
169
169
|
|
|
170
170
|
return target || null
|
|
171
171
|
}
|
package/core/validator.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
const { default: Schema } = require('async-validator')
|
|
1
|
+
const { default: Schema } = require('async-validator')
|
|
2
2
|
|
|
3
3
|
module.exports = class Validator {
|
|
4
4
|
constructor(descriptor) {
|
|
5
|
-
this.validator = new Schema(descriptor)
|
|
5
|
+
this.validator = new Schema(descriptor)
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
async validate(data) {
|
|
9
9
|
try {
|
|
10
|
-
return await this.validator.validate(data)
|
|
10
|
+
return await this.validator.validate(data)
|
|
11
11
|
} catch (e) {
|
|
12
|
-
throw new Error(
|
|
12
|
+
throw new Error(
|
|
13
|
+
e.errors.map(
|
|
14
|
+
(item) =>
|
|
15
|
+
`${process.env.NODE_ENV === 'production' ? '' : item.field + ':'}${
|
|
16
|
+
item.message
|
|
17
|
+
}`
|
|
18
|
+
)
|
|
19
|
+
)
|
|
13
20
|
}
|
|
14
21
|
}
|
|
15
|
-
}
|
|
22
|
+
}
|