@cloud-cli/px 4.2.6 → 4.2.7

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.
@@ -6,6 +6,7 @@ export declare class ProxyManager {
6
6
  updateProxy(options: WithOptionalProps<Proxy>): Promise<Proxy>;
7
7
  removeProxy(options: WithOptionalProps<DomainAndTarget>): Promise<boolean>;
8
8
  getDomainList(): Promise<string[]>;
9
+ getProxyListWithContainers(): Promise<Proxy[]>;
9
10
  getProxyList(filters?: Partial<Proxy>): Promise<Proxy[]>;
10
11
  getProxyListForDomain(options: WithOptionalProps<DomainName>): Promise<Proxy[]>;
11
12
  reload(): Promise<void>;
@@ -100,10 +100,18 @@ export class ProxyManager {
100
100
  const proxies = await this.getProxyList();
101
101
  return proxies.map((proxy) => proxy.domain);
102
102
  }
103
- async getProxyList(filters = {}) {
103
+ async getProxyListWithContainers() {
104
104
  const staticRoutes = getAll();
105
- const containers = await this.getRunningContainers();
106
- const list = [...staticRoutes, ...containers.map(readProxyFromContainer)];
105
+ const containers = (await this.getRunningContainers()).map(readProxyFromContainer);
106
+ const containerDomains = containers.map(c => c.domain.split('/')[0]);
107
+ const list = [
108
+ ...staticRoutes.filter(t => !containerDomains.includes(t.domain)),
109
+ ...containers,
110
+ ];
111
+ return list;
112
+ }
113
+ async getProxyList(filters = {}) {
114
+ const list = await this.getProxyListWithContainers();
107
115
  const keys = Object.keys(filters);
108
116
  if (!keys.length) {
109
117
  return list;
@@ -119,9 +127,7 @@ export class ProxyManager {
119
127
  return all.filter((p) => p.domain === options.domain);
120
128
  }
121
129
  async reload() {
122
- const targets = await getAll();
123
- const containers = await this.getRunningContainers();
124
- const all = [...targets, ...containers.map(readProxyFromContainer)];
130
+ const all = await this.getProxyListWithContainers();
125
131
  px.reset();
126
132
  for (const t of all) {
127
133
  const [domain, path = ""] = t.domain.split("/");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-cli/px",
3
- "version": "4.2.6",
3
+ "version": "4.2.7",
4
4
  "description": "Reverse Proxy",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",