q-koa 11.4.4 → 11.4.6

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
@@ -42,6 +42,7 @@ const {
42
42
  miLimit,
43
43
  } = require('./middlewares')
44
44
  const Validator = require('./validator')
45
+ const { ServiceError } = require('./errors')
45
46
 
46
47
  let spinner
47
48
 
@@ -1826,7 +1827,20 @@ class APP {
1826
1827
  ? ['updated_at']
1827
1828
  : ['created_at', 'updated_at']
1828
1829
 
1829
- const newData = _.omit(_.omitBy(ctx.request.body, _.isNull), _exclude)
1830
+ const newData = _.omit(
1831
+ _.omitBy(
1832
+ ctx.request.body,
1833
+ (value, key) =>
1834
+ _.isNull(value) &&
1835
+ !(
1836
+ ctx.app[appName].attributes &&
1837
+ ctx.app[appName].attributes[controller] &&
1838
+ ctx.app[appName].attributes[controller][key] &&
1839
+ ctx.app[appName].attributes[controller][key].allowNull
1840
+ )
1841
+ ),
1842
+ _exclude
1843
+ )
1830
1844
 
1831
1845
  const flag = await app[appName].model[controller][fn]({
1832
1846
  createdid: ctx.request[`${appName}-user`]
@@ -1917,6 +1931,7 @@ APP.Sequelize = Sequelize
1917
1931
  APP.lodash = _
1918
1932
  APP.Random = Random
1919
1933
  APP.Validator = Validator
1934
+ APP.ServiceError = ServiceError
1920
1935
  APP.moment = moment
1921
1936
  global.moment = moment
1922
1937
  global.Sequelize = Sequelize
package/core/errors.js ADDED
@@ -0,0 +1,8 @@
1
+ class ServiceError extends Error {
2
+ constructor(message) {
3
+ super(message)
4
+ this.type = 'service'
5
+ }
6
+ }
7
+
8
+ exports.ServiceError = ServiceError
@@ -6,6 +6,7 @@ const axios = require('axios')
6
6
  exports.initData = async ({ includes, excludes, app, ctx }) => {
7
7
  const appConfig = getConfig(app)
8
8
  const { version: cacheVersion } = await appConfig.getObject('base')
9
+
9
10
  const apiVersion = ctx.request.header.version
10
11
  const config = ctx.request.header.config
11
12
 
@@ -275,6 +276,9 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
275
276
  }),
276
277
  {}
277
278
  )
279
+ if (obj.setting && apiVersion && !cacheVersion) {
280
+ console.log(`version没有后端缓存`)
281
+ }
278
282
  if (obj.setting && apiVersion && cacheVersion) {
279
283
  let target = null
280
284
  if (config) {
@@ -30,7 +30,7 @@ exports.miErrors = () => async (ctx, next) => {
30
30
  content: e.stack,
31
31
  header: ctx.request.header,
32
32
  }
33
- if (app && app.model && app.model.log) {
33
+ if (['service'].includes(e.type) && app && app.model && app.model.log) {
34
34
  app.model.log.upsert(errorData)
35
35
  }
36
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "11.4.4",
3
+ "version": "11.4.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {