@abtnode/util 1.7.11 → 1.7.12

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.
@@ -0,0 +1,24 @@
1
+ const get = require('lodash/get');
2
+
3
+ // Format context: https://github.com/graphql/express-graphql
4
+ module.exports = (ctx = {}) => {
5
+ if (ctx && ctx.user) {
6
+ delete ctx.user.avatar;
7
+ }
8
+
9
+ const safeGet = (key, _default = '') =>
10
+ (typeof ctx.get === 'function' ? ctx.get(key) : get(ctx, `headers[${key}]`)) || _default;
11
+ const port = process.env.NODE_ENV === 'production' ? safeGet('x-real-port') : '';
12
+ const result = {
13
+ ip: safeGet('x-real-ip', '127.0.0.1'),
14
+ ua: safeGet('user-agent'),
15
+ protocol: safeGet('x-real-protocol').replace(/:$/, '') || 'http',
16
+ user: ctx.user || {},
17
+ url: ctx.originalUrl,
18
+ query: ctx.query,
19
+ hostname: safeGet('x-real-hostname'),
20
+ port: Number(port) === 80 ? '' : Number(port),
21
+ };
22
+
23
+ return result;
24
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.7.11",
6
+ "version": "1.7.12",
7
7
  "description": "ArcBlock's JavaScript utility",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,9 +18,9 @@
18
18
  "author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@ocap/mcrypto": "^1.16.5",
22
- "@ocap/util": "^1.16.5",
23
- "@ocap/wallet": "^1.16.5",
21
+ "@ocap/mcrypto": "^1.16.6",
22
+ "@ocap/util": "^1.16.6",
23
+ "@ocap/wallet": "^1.16.6",
24
24
  "axios": "^0.26.1",
25
25
  "axios-mock-adapter": "^1.20.0",
26
26
  "axon": "^2.0.3",
@@ -54,5 +54,5 @@
54
54
  "fs-extra": "^10.0.1",
55
55
  "jest": "^27.4.5"
56
56
  },
57
- "gitHead": "84e741e6b37e47d52bf834ce3ace8ed601d0896c"
57
+ "gitHead": "afc78b9cb92448676149262fb02432bc256a5524"
58
58
  }