@qingfu/core-env 0.1.19 → 0.1.22
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/server.js +5 -2
- package/lib/utils.js +24 -7
- package/package.json +12 -12
package/lib/server.js
CHANGED
|
@@ -11,13 +11,16 @@ if ( process.env.HTTP_PORT ) {
|
|
|
11
11
|
app.use( require( 'koa-methodoverride' )() );
|
|
12
12
|
app.use( require( 'koa-logger' )() );
|
|
13
13
|
app.use( dontparse );
|
|
14
|
-
app.use( require( 'koa-bodyparser' )({ enableTypes: [ 'json', 'form', 'xml' ]
|
|
14
|
+
app.use( require( 'koa-bodyparser' )({ enableTypes: [ 'json', 'form', 'xml' ],
|
|
15
|
+
formLimit: '10mb', jsonLimit: '10mb', textLimit: '10mb', xmlLimit: '10mb' }));
|
|
15
16
|
app.use( require( 'koa-favicon' )( path.join( __dirname, '../favicon.ico' )));
|
|
16
17
|
app.use( error );
|
|
17
18
|
require( 'koa-qs' )( app );
|
|
18
19
|
|
|
19
20
|
async function dontparse( ctx, next ) {
|
|
20
|
-
|
|
21
|
+
let ignores = [ '/dontparse', '/ignorebody' ];
|
|
22
|
+
if ( ignores.some( v => ctx.path.includes( v )))
|
|
23
|
+
ctx.disableBodyParser = true;
|
|
21
24
|
await next();
|
|
22
25
|
};
|
|
23
26
|
|
package/lib/utils.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
1
|
+
const fs = require( 'fs' );
|
|
2
|
+
const _ = require( 'lodash' );
|
|
3
|
+
const crypto = require( 'crypto' );
|
|
4
|
+
const xml2js = require( 'xml2js' );
|
|
5
|
+
const xlsx = require( 'xlsx' );
|
|
6
|
+
const pinyin = require( 'pinyin' );
|
|
7
|
+
const qrcode = require( 'qr-image' );
|
|
8
|
+
const request = require( 'superagent' );
|
|
9
|
+
const utils = global.utils = module.exports = {};
|
|
8
10
|
|
|
9
11
|
utils.xml2json = async xml => {
|
|
10
12
|
let options = { explicitRoot: false, explicitArray: false };
|
|
@@ -222,3 +224,18 @@ utils.identityValidate = identity => {
|
|
|
222
224
|
if ( parity[ sum % 11 ] != identity[ 17 ]) return false;
|
|
223
225
|
else return true;
|
|
224
226
|
};
|
|
227
|
+
|
|
228
|
+
utils.fetchBig = async ({ url, dest, retry = 0 }) => {
|
|
229
|
+
try {
|
|
230
|
+
return await new Promise(( resolve, reject ) => {
|
|
231
|
+
let writeStream = fs.createWriteStream( dest );
|
|
232
|
+
let readStream = request.get( url );
|
|
233
|
+
readStream.pipe( writeStream );
|
|
234
|
+
readStream.on( 'error', reject );
|
|
235
|
+
writeStream.on( 'finish', resolve );
|
|
236
|
+
});
|
|
237
|
+
} catch ( err ) {
|
|
238
|
+
if ( !retry-- ) throw err;
|
|
239
|
+
return utils.fetchBig({ url, dest, retry });
|
|
240
|
+
}
|
|
241
|
+
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qingfu/core-env",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"readmeFilename": "README.md",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@koa/cors": "3.
|
|
6
|
+
"@koa/cors": "3.3.0",
|
|
7
7
|
"@koa/router": "10.1.1",
|
|
8
|
-
"bull": "4.
|
|
8
|
+
"bull": "4.8.2",
|
|
9
9
|
"busboy": "0.3.1",
|
|
10
|
-
"cookie": "0.
|
|
10
|
+
"cookie": "0.5.0",
|
|
11
11
|
"dotenv-extended": "2.9.0",
|
|
12
|
-
"glob": "
|
|
12
|
+
"glob": "8.0.1",
|
|
13
13
|
"ioredis": "4.28.5",
|
|
14
14
|
"jsonwebtoken": "8.5.1",
|
|
15
15
|
"koa": "2.13.4",
|
|
@@ -20,24 +20,24 @@
|
|
|
20
20
|
"koa-methodoverride": "2.0.0",
|
|
21
21
|
"koa-qs": "3.0.0",
|
|
22
22
|
"lodash": "4.17.21",
|
|
23
|
-
"moleculer": "0.14.
|
|
24
|
-
"mongoose": "6.
|
|
23
|
+
"moleculer": "0.14.20",
|
|
24
|
+
"mongoose": "6.3.1",
|
|
25
25
|
"mongoose-cast-aggregation": "0.2.1",
|
|
26
|
-
"mongoose-geojson-schema": "2.
|
|
26
|
+
"mongoose-geojson-schema": "2.2.2",
|
|
27
27
|
"mongoose-lean-defaults": "2.1.0",
|
|
28
|
-
"mongoose-lean-getters": "0.3.
|
|
28
|
+
"mongoose-lean-getters": "0.3.2",
|
|
29
29
|
"mongoose-lean-virtuals": "0.9.0",
|
|
30
30
|
"ms": "2.1.3",
|
|
31
31
|
"notepack.io": "2.3.0",
|
|
32
|
-
"pinyin": "2.11.
|
|
32
|
+
"pinyin": "2.11.2",
|
|
33
33
|
"primus": "8.0.5",
|
|
34
34
|
"primus-rooms": "3.4.1",
|
|
35
35
|
"qr-image": "3.2.0",
|
|
36
36
|
"superagent": "7.1.1",
|
|
37
37
|
"wechat-encrypt": "1.1.1",
|
|
38
|
-
"winston": "3.
|
|
38
|
+
"winston": "3.7.2",
|
|
39
39
|
"winston-mongodb": "5.0.7",
|
|
40
|
-
"xlsx": "0.18.
|
|
40
|
+
"xlsx": "0.18.5",
|
|
41
41
|
"xml2js": "0.4.23"
|
|
42
42
|
}
|
|
43
43
|
}
|