@abtnode/router-provider 1.16.13-beta-55b3e93d → 1.16.13-beta-423a40b1

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.
@@ -379,6 +379,11 @@ class NginxProvider extends BaseProvider {
379
379
  return;
380
380
  }
381
381
 
382
+ if (type === ROUTING_RULE_TYPES.GENERAL_REWRITE) {
383
+ this._addRewriteTypeLocation(args);
384
+ return;
385
+ }
386
+
382
387
  if (type === ROUTING_RULE_TYPES.GENERAL_PROXY) {
383
388
  this._addGeneralProxyLocation(args);
384
389
  return;
@@ -459,6 +464,7 @@ class NginxProvider extends BaseProvider {
459
464
  type,
460
465
  commonHeaders,
461
466
  cacheGroup,
467
+ pageGroup,
462
468
  }) {
463
469
  server._add('location', concatPath(prefix, suffix));
464
470
 
@@ -482,6 +488,9 @@ class NginxProvider extends BaseProvider {
482
488
  }
483
489
 
484
490
  location._add('include', 'includes/proxy');
491
+ if (pageGroup) {
492
+ location._add('proxy_set_header', `X-Page-Group "${pageGroup}"`);
493
+ }
485
494
 
486
495
  // kill cache
487
496
  if (this.cacheEnabled === false) {
@@ -558,6 +567,13 @@ class NginxProvider extends BaseProvider {
558
567
  }
559
568
  }
560
569
 
570
+ _addRewriteTypeLocation({ server, url, prefix, suffix, corsAllowedOrigins, serverName }) {
571
+ server._add('location', concatPath(prefix, suffix));
572
+ const location = this._getLastLocation(server);
573
+ this._addCors({ location, corsAllowedOrigins, serverName });
574
+ location._add('rewrite', `^${prefix}(.*) ${url}$1 last`);
575
+ }
576
+
561
577
  _addNotFoundLocation({ server, prefix, suffix }) {
562
578
  server._add('location', concatPath(prefix, suffix));
563
579
  const location = this._getLastLocation(server);
package/lib/util.js CHANGED
@@ -72,6 +72,11 @@ const formatRoutingTable = (routingTable, onRule) => {
72
72
  }
73
73
 
74
74
  (site.rules || []).forEach((x) => {
75
+ if (x.to.type === ROUTING_RULE_TYPES.COMPONENT) {
76
+ console.warn(`Rule type is dropped: ${x.to.type}`, x);
77
+ return;
78
+ }
79
+
75
80
  const prefix = trimEndSlash(x.from.pathPrefix || '/');
76
81
  const groupPrefix = trimEndSlash(x.from.groupPathPrefix || '/');
77
82
  const suffix = trimEndSlash(x.from.pathSuffix || '');
@@ -87,6 +92,8 @@ const formatRoutingTable = (routingTable, onRule) => {
87
92
  if (x.to.type === ROUTING_RULE_TYPES.REDIRECT) {
88
93
  rule.redirectCode = x.to.redirectCode || 302;
89
94
  rule.url = x.to.url;
95
+ } else if (x.to.type === ROUTING_RULE_TYPES.GENERAL_REWRITE) {
96
+ rule.url = x.to.url;
90
97
  } else {
91
98
  rule.port = +x.to.port;
92
99
  rule.did = x.to.did;
@@ -95,6 +102,7 @@ const formatRoutingTable = (routingTable, onRule) => {
95
102
  rule.target = trimEndSlash(normalizePathPrefix(x.to.target || '/'));
96
103
  rule.targetPrefix = x.to.targetPrefix || '';
97
104
  rule.services = x.services || [];
105
+ rule.pageGroup = x.to.pageGroup;
98
106
  }
99
107
 
100
108
  const tmpPath = concatPath(prefix, suffix);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/router-provider",
3
- "version": "1.16.13-beta-55b3e93d",
3
+ "version": "1.16.13-beta-423a40b1",
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.16.13-beta-55b3e93d",
36
- "@abtnode/logger": "1.16.13-beta-55b3e93d",
37
- "@abtnode/router-templates": "1.16.13-beta-55b3e93d",
38
- "@abtnode/util": "1.16.13-beta-55b3e93d",
35
+ "@abtnode/constant": "1.16.13-beta-423a40b1",
36
+ "@abtnode/logger": "1.16.13-beta-423a40b1",
37
+ "@abtnode/router-templates": "1.16.13-beta-423a40b1",
38
+ "@abtnode/util": "1.16.13-beta-423a40b1",
39
39
  "@arcblock/http-proxy": "^1.19.1",
40
40
  "axios": "^0.27.2",
41
41
  "debug": "^4.3.4",
@@ -60,5 +60,5 @@
60
60
  "bluebird": "^3.7.2",
61
61
  "fs-extra": "^10.1.0"
62
62
  },
63
- "gitHead": "1c734de99ff70fad99e9cc3fb55834e0bb6f5bfd"
63
+ "gitHead": "1aee04f45042bd4784ca72f9f8b93918980be4d4"
64
64
  }