@qingfu/core-env 0.3.4 → 0.3.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/lib/broker.js CHANGED
@@ -38,10 +38,7 @@ if ( process.env.BROKER_URI ) {
38
38
  nonce: ctx.meta.nonce,
39
39
  timestamp: ctx.meta.timestamp
40
40
  });
41
- if ( !nonce ) throw Object.assign(
42
- new MoleculerError( 'NONCE_CONFLICT', 409 ),
43
- { expose: true }
44
- );
41
+ if ( !nonce ) throw new MoleculerError( 'NONCE_CONFLICT', 409, 'NONCE_CONFLICT', { expose: true });
45
42
  }
46
43
  return await next( ctx );
47
44
  };
package/lib/database.js CHANGED
@@ -115,7 +115,7 @@ function batchPlugin( schema ) {
115
115
  { new: true, runValidators: true }
116
116
  );
117
117
  if ( !model ) return isMulti ? [] : null;
118
- let results = model[ path ].filter( v => pathID.find( id => id.toString() === _.get( v, subpath ).toString() ));
118
+ let results = _.get( model, path ).filter( v => pathID.find( id => id.toString() === _.get( v, subpath ).toString() ));
119
119
  return { model, data: isMulti ? results : results[ 0 ]};
120
120
  };
121
121
  schema.statics.pathDelete = async function({ query, update, path, subpath, pathID }) {
@@ -128,7 +128,7 @@ function batchPlugin( schema ) {
128
128
  { new: false, runValidators: true }
129
129
  );
130
130
  if ( !model ) return isMulti ? [] : null;
131
- let results = model[ path ].filter( v => pathID.find( id => id.toString() === _.get( v, subpath ).toString() ));
131
+ let results = _.get( model, path ).filter( v => pathID.find( id => id.toString() === _.get( v, subpath ).toString() ));
132
132
  return { model, data: isMulti ? results : results[ 0 ]};
133
133
  };
134
134
  schema.statics.pathUpdate = async function({ query, update, path, subpath, pathID, data }) {
@@ -143,7 +143,7 @@ function batchPlugin( schema ) {
143
143
  { ...update, $set: _.transform( item, ( r, v, k ) => { r[ `${ path }.$.${ k }` ] = v; }, {})},
144
144
  { new: true, runValidators: true }
145
145
  );
146
- return model && { model, data: model[ path ].find( v => pathID[ i ].toString() === _.get( v, subpath ).toString() )};
146
+ return model && { model, data: _.get( model, path ).find( v => pathID[ i ].toString() === _.get( v, subpath ).toString() )};
147
147
  })));
148
148
  if ( !batch.length ) return isMulti ? [] : null;
149
149
  let model = batch[ 0 ].model, results = batch.map( v => v.data );
package/lib/server.js CHANGED
@@ -42,7 +42,7 @@ if ( process.env.HTTP_PORT ) {
42
42
  err.code && err.name !== 'MongoServerError' && +err.code ||
43
43
  err.status && err.status ||
44
44
  err.message && +err.message || 500;
45
- ctx.message = err.expose && !+err.message && err.message || ctx.message;
45
+ ctx.message = _.get( err, 'data.expose', err.expose ) && !+err.message && err.message || ctx.message;
46
46
  ctx.app.emit( 'error', err, ctx );
47
47
  let accepts = ctx.accepts( 'json', 'html', 'text' );
48
48
  let data = { status: ctx.status, message: ctx.message, ...( err.body || {} )};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qingfu/core-env",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "readmeFilename": "README.md",
5
5
  "dependencies": {
6
6
  "@koa/cors": "5.0.0",