@abtnode/router-provider 1.8.67-beta-794a8082 → 1.8.67

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.
@@ -79,14 +79,12 @@ const parseServerName = (domain) => {
79
79
 
80
80
  class NginxProvider extends BaseProvider {
81
81
  /**
82
- * @param {object} options
83
- * @param {string} options.configDir
84
- * @param {number} options.httpPort
85
- * @param {number} options.httpsPort
86
- * @param {boolean} [options.cacheEnabled]
87
- * @param {boolean} [options.isTest]
82
+ * @param {string} configDir
83
+ * @param {number} httpPort
84
+ * @param {number} httpPort
85
+ * @param {number} cacheDisabled
88
86
  */
89
- constructor({ configDir, httpPort, httpsPort, cacheEnabled = true, isTest = false }) {
87
+ constructor({ configDir, httpPort, httpsPort, cacheDisabled, isTest }) {
90
88
  super('nginx');
91
89
  if (!configDir) {
92
90
  throw new Error('invalid configDir');
@@ -113,7 +111,7 @@ class NginxProvider extends BaseProvider {
113
111
 
114
112
  this.httpPort = decideHttpPort(httpPort);
115
113
  this.httpsPort = decideHttpsPort(httpsPort);
116
- this.cacheEnabled = !!cacheEnabled;
114
+ this.cacheDisabled = !!cacheDisabled;
117
115
  this.isHttp2Supported = this._isHttp2Supported();
118
116
  this.conf = null; // nginx `conf` object
119
117
 
@@ -121,7 +119,7 @@ class NginxProvider extends BaseProvider {
121
119
  configDir,
122
120
  httpPort: this.httpPort,
123
121
  httpsPort: this.httpsPort,
124
- cacheEnabled: this.cacheEnabled,
122
+ cacheDisabled: this.cacheDisabled,
125
123
  });
126
124
 
127
125
  // ensure directories
@@ -161,16 +159,11 @@ class NginxProvider extends BaseProvider {
161
159
  services = [],
162
160
  nodeInfo = {},
163
161
  requestLimit,
164
- cacheEnabled,
165
162
  } = {}) {
166
163
  if (!Array.isArray(routingTable)) {
167
164
  throw new Error('routingTable must be an array');
168
165
  }
169
166
 
170
- if (typeof cacheEnabled !== 'undefined') {
171
- this.cacheEnabled = !!cacheEnabled;
172
- }
173
-
174
167
  this._addWwwFiles(nodeInfo);
175
168
 
176
169
  // eslint-disable-next-line consistent-return
@@ -439,6 +432,12 @@ class NginxProvider extends BaseProvider {
439
432
  * rewrite ^/flash/(.*) /$1 break;
440
433
  * proxy_pass http://127.0.0.1:8090;
441
434
  * }
435
+ * @param {object} server
436
+ * @param {number} port
437
+ * @param {string} pathPrefix
438
+ * @param {string} pathSuffix
439
+ * @param {string} did app did
440
+ * @param {string} componentId component id
442
441
  */
443
442
  _addBlockletTypeLocation({
444
443
  server,
@@ -451,7 +450,6 @@ class NginxProvider extends BaseProvider {
451
450
  componentId,
452
451
  corsAllowedOrigins,
453
452
  target,
454
- targetPrefix, // used to strip prefix from target
455
453
  ruleId,
456
454
  type,
457
455
  commonHeaders,
@@ -473,15 +471,14 @@ class NginxProvider extends BaseProvider {
473
471
  if (did) {
474
472
  location._add('set', `$did "${did}"`);
475
473
  location._add('proxy_set_header', `X-Blocklet-Did "${did}"`);
476
- if (componentId) {
477
- location._add('proxy_set_header', `X-Blocklet-Component-Id "${componentId}"`);
478
- }
474
+ location._add('proxy_set_header', `X-Blocklet-Component-Id "${componentId}"`);
479
475
  }
480
476
 
481
477
  location._add('include', 'includes/proxy');
482
478
 
483
479
  // kill cache
484
- if (this.cacheEnabled === false) {
480
+ // TODO: 这个放在管理端的 Gateway 配置中
481
+ if (this.cacheDisabled) {
485
482
  location._add('expires', '-1');
486
483
  } else if (ROUTER_CACHE_GROUPS[cacheGroup]) {
487
484
  location._add('proxy_cache', cacheGroup);
@@ -492,12 +489,9 @@ class NginxProvider extends BaseProvider {
492
489
  // Redirect blocklet traffic
493
490
  if (type === ROUTING_RULE_TYPES.BLOCKLET) {
494
491
  // FIXME: logic related to server gateway should not in provider
495
- let rewritePathPrefix = prefix.replace(WELLKNOWN_SERVICE_PATH_PREFIX, '').replace(USER_AVATAR_PATH_PREFIX, '');
492
+ const rewritePathPrefix = prefix.replace(WELLKNOWN_SERVICE_PATH_PREFIX, '').replace(USER_AVATAR_PATH_PREFIX, '');
496
493
 
497
494
  // Add header
498
- if (targetPrefix) {
499
- rewritePathPrefix = rewritePathPrefix.replace(targetPrefix, '');
500
- }
501
495
 
502
496
  location._add('proxy_set_header', `X-Path-Prefix "${rewritePathPrefix}"`);
503
497
  if (groupPrefix) {
package/lib/util.js CHANGED
@@ -89,7 +89,6 @@ const formatRoutingTable = (routingTable, onRule) => {
89
89
  rule.cacheGroup = x.to.cacheGroup;
90
90
  rule.componentId = x.to.componentId;
91
91
  rule.target = trimEndSlash(normalizePathPrefix(x.to.target || '/'));
92
- rule.targetPrefix = x.to.targetPrefix || '';
93
92
  rule.services = x.services || [];
94
93
  }
95
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/router-provider",
3
- "version": "1.8.67-beta-794a8082",
3
+ "version": "1.8.67",
4
4
  "description": "Routing engine implementations for abt node",
5
5
  "author": "polunzh <polunzh@gmail.com>",
6
6
  "homepage": "https://github.com/ArcBlock/blocklet-server#readme",
@@ -32,10 +32,10 @@
32
32
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@abtnode/constant": "1.8.67-beta-794a8082",
36
- "@abtnode/logger": "1.8.67-beta-794a8082",
37
- "@abtnode/router-templates": "1.8.67-beta-794a8082",
38
- "@abtnode/util": "1.8.67-beta-794a8082",
35
+ "@abtnode/constant": "1.8.67",
36
+ "@abtnode/logger": "1.8.67",
37
+ "@abtnode/router-templates": "1.8.67",
38
+ "@abtnode/util": "1.8.67",
39
39
  "axios": "^0.27.2",
40
40
  "debug": "^4.3.4",
41
41
  "find-process": "^1.4.7",
@@ -62,5 +62,5 @@
62
62
  "fs-extra": "^10.1.0",
63
63
  "needle": "^3.1.0"
64
64
  },
65
- "gitHead": "f4ad32bea4d80b12971fb6bef941bdbe2af6a834"
65
+ "gitHead": "543dbadffd29dc4f096261e136a2a306885d6508"
66
66
  }