@qingfu/core-env 0.1.16 → 0.1.19
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 +5 -3
- package/lib/helper.js +10 -3
- package/package.json +4 -4
package/lib/broker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
if ( process.env.BROKER_URI ) {
|
|
2
2
|
|
|
3
|
-
const { ServiceBroker, Errors } = require( 'moleculer' );
|
|
3
|
+
const { ServiceBroker, Errors: { MoleculerError }} = require( 'moleculer' );
|
|
4
4
|
const defaultTCP = { maxPacketSize: 20 * 1024 * 1024 };
|
|
5
5
|
const namespaces = process.env.BROKER_NS.split( /,?\s+/ ).filter( Boolean );
|
|
6
6
|
const transporters = process.env.BROKER_URI.split( /,?\s+/ ).filter( Boolean );
|
|
@@ -38,8 +38,10 @@ if ( process.env.BROKER_URI ) {
|
|
|
38
38
|
nonce: ctx.meta.nonce,
|
|
39
39
|
timestamp: ctx.meta.timestamp
|
|
40
40
|
});
|
|
41
|
-
if ( !nonce ) throw
|
|
42
|
-
|
|
41
|
+
if ( !nonce ) throw Object.assign(
|
|
42
|
+
new MoleculerError( 'NONCE_CONFLICT', 409 ),
|
|
43
|
+
{ expose: true }
|
|
44
|
+
);
|
|
43
45
|
}
|
|
44
46
|
return await next( ctx );
|
|
45
47
|
};
|
package/lib/helper.js
CHANGED
|
@@ -57,11 +57,18 @@ helper.parseLike = ( ...fields ) => {
|
|
|
57
57
|
let parse = data => {
|
|
58
58
|
let regex = { $regex: data.like, $options: 'i' };
|
|
59
59
|
let $or = fields.map( field => ({[ field ]: regex }));
|
|
60
|
-
|
|
60
|
+
if ( !data.like ) {
|
|
61
|
+
return _.omit( data, 'like' );
|
|
62
|
+
} else if ( data.$or ) {
|
|
63
|
+
data.$or.forEach( v => Object.assign( v, { $or }));
|
|
64
|
+
return _.omit( data, 'like' );
|
|
65
|
+
} else {
|
|
66
|
+
return { $or, ..._.omit( data, 'like' )};
|
|
67
|
+
}
|
|
61
68
|
};
|
|
62
69
|
return async ( ctx, next ) => {
|
|
63
|
-
if ( ctx.query
|
|
64
|
-
if ( ctx.request.body
|
|
70
|
+
if ( _.has( ctx.query, 'like' )) ctx.query = parse( ctx.query );
|
|
71
|
+
if ( _.has( ctx.request.body, 'like' )) ctx.request.body = parse( ctx.request.body );
|
|
65
72
|
return await next();
|
|
66
73
|
};
|
|
67
74
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qingfu/core-env",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"readmeFilename": "README.md",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@koa/cors": "3.1.0",
|
|
7
7
|
"@koa/router": "10.1.1",
|
|
8
|
-
"bull": "4.
|
|
8
|
+
"bull": "4.6.2",
|
|
9
9
|
"busboy": "0.3.1",
|
|
10
10
|
"cookie": "0.4.2",
|
|
11
11
|
"dotenv-extended": "2.9.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"koa-qs": "3.0.0",
|
|
22
22
|
"lodash": "4.17.21",
|
|
23
23
|
"moleculer": "0.14.19",
|
|
24
|
-
"mongoose": "6.2.
|
|
24
|
+
"mongoose": "6.2.4",
|
|
25
25
|
"mongoose-cast-aggregation": "0.2.1",
|
|
26
26
|
"mongoose-geojson-schema": "2.1.7",
|
|
27
27
|
"mongoose-lean-defaults": "2.1.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"mongoose-lean-virtuals": "0.9.0",
|
|
30
30
|
"ms": "2.1.3",
|
|
31
31
|
"notepack.io": "2.3.0",
|
|
32
|
-
"pinyin": "2.
|
|
32
|
+
"pinyin": "2.11.0",
|
|
33
33
|
"primus": "8.0.5",
|
|
34
34
|
"primus-rooms": "3.4.1",
|
|
35
35
|
"qr-image": "3.2.0",
|