q-koa 11.4.6 → 11.5.0
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 +5 -0
- package/core/middlewares.js +7 -2
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -1930,13 +1930,18 @@ class APP {
|
|
|
1930
1930
|
APP.Sequelize = Sequelize
|
|
1931
1931
|
APP.lodash = _
|
|
1932
1932
|
APP.Random = Random
|
|
1933
|
+
|
|
1933
1934
|
APP.Validator = Validator
|
|
1934
1935
|
APP.ServiceError = ServiceError
|
|
1935
1936
|
APP.moment = moment
|
|
1937
|
+
|
|
1936
1938
|
global.moment = moment
|
|
1937
1939
|
global.Sequelize = Sequelize
|
|
1938
1940
|
global.lodash = _
|
|
1939
1941
|
|
|
1942
|
+
global.Validator = Validator
|
|
1943
|
+
global.ServiceError = ServiceError
|
|
1944
|
+
|
|
1940
1945
|
APP.sleep = (time) => new Promise((resolve) => setTimeout(resolve, time * 1000))
|
|
1941
1946
|
|
|
1942
1947
|
APP.getService = (name) => {
|
package/core/middlewares.js
CHANGED
|
@@ -30,8 +30,13 @@ exports.miErrors = () => async (ctx, next) => {
|
|
|
30
30
|
content: e.stack,
|
|
31
31
|
header: ctx.request.header,
|
|
32
32
|
}
|
|
33
|
-
if (
|
|
34
|
-
|
|
33
|
+
if (app && app.model && app.model.log) {
|
|
34
|
+
if (!['service'].includes(e.type)) {
|
|
35
|
+
app.model.log.upsert(errorData)
|
|
36
|
+
if (e.type === 'transaction') {
|
|
37
|
+
return ctx.ERROR('发生错误了')
|
|
38
|
+
}
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
return ctx.ERROR(e.message || '发生错误了')
|