@cloud-cli/px 4.4.3 → 4.4.5

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { help, init } from "@cloud-cli/cli";
2
- import { DomainAndTarget, DomainName, Proxy, WithOptionalProps } from "./types.js";
1
+ import { help, init } from '@cloud-cli/cli';
2
+ import { DomainAndTarget, DomainName, Proxy, WithOptionalProps } from './types.js';
3
3
  declare const _default: {
4
4
  add(options: WithOptionalProps<Proxy>): Promise<Proxy>;
5
5
  remove(options: WithOptionalProps<DomainAndTarget>): Promise<boolean>;
@@ -8,6 +8,7 @@ declare const _default: {
8
8
  get(options: DomainName): Promise<Proxy[]>;
9
9
  domains(): Promise<string[]>;
10
10
  reload(): Promise<void>;
11
+ restart(): Promise<void>;
11
12
  [init](): Promise<import("@cloud-cli/proxy").ProxyServer>;
12
13
  [help](): string;
13
14
  };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { help, init, logInfo } from "@cloud-cli/cli";
2
- import { ProxyManager } from "./proxy-manager.js";
1
+ import { help, init, logInfo } from '@cloud-cli/cli';
2
+ import { ProxyManager } from './proxy-manager.js';
3
3
  const manager = new ProxyManager();
4
4
  export default {
5
5
  async add(options) {
@@ -21,25 +21,35 @@ export default {
21
21
  return manager.getDomainList();
22
22
  },
23
23
  async reload() {
24
- logInfo("Reloading proxy server");
24
+ logInfo('Reloading proxy configuration');
25
25
  return await manager.reload();
26
26
  },
27
+ async restart() {
28
+ logInfo('Restarting server');
29
+ return await manager.restart();
30
+ },
27
31
  async [init]() {
28
- await manager.reload();
32
+ await manager.restart();
29
33
  return manager.server;
30
34
  },
31
35
  [help]() {
32
36
  return `Manages reverse proxy entries
33
37
 
34
38
  Available commands:
35
- px.add --domain <domain> --target <url> [--cors] [--redirect] [--preserveHost] [--redirectUrl <url>] [--headers <headers>] [--authorization <value>] - Add an entry
36
- px.remove --domain <domain> - Remove an entry
37
- px.update --domain <domain> [proxy options] - Update an entry
38
- px.list [--domain <domain>] [--target <url>] [proxy options] - List matching entries
39
- px.get --domain <domain> - Get entries for a domain
40
- px.domains - List configured domains
41
- px.reload - Reload all proxy entries
39
+ px.add
40
+ px.update
41
+ --domain <domain> <proxy options>
42
+ px.remove
43
+ --domain <domain>
44
+ px.list
45
+ [--domain <domain>] <proxy options>
46
+ px.get
47
+ --domain <domain>
48
+ px.domains
49
+ px.reload
50
+ px.restart
42
51
 
43
- Proxy options: domain, target, cors, redirect, preserveHost, redirectUrl, headers, authorization`;
52
+ Proxy options:
53
+ --target <url> [--cors] [--redirect] [--preserveHost] [--redirectUrl <url>] [--headers <headers>] [--authorization <value>]`;
44
54
  },
45
55
  };
@@ -9,9 +9,8 @@ export declare class ProxyManager {
9
9
  getProxyListWithContainers(): Promise<Proxy[]>;
10
10
  getProxyList(filters?: Partial<Proxy>): Promise<Proxy[]>;
11
11
  getProxyListForDomain(options: WithOptionalProps<DomainName>): Promise<Proxy[]>;
12
- reload(options?: {
13
- servers?: Boolean;
14
- }): Promise<void>;
12
+ restart(): Promise<void>;
13
+ reload(): Promise<void>;
15
14
  private loadProxy;
16
15
  getRunningContainers(): Promise<DockerContainer[]>;
17
16
  }
@@ -1,4 +1,4 @@
1
- import { getStorage, getConfig } from '@cloud-cli/cli';
1
+ import { getStorage, getConfig, logInfo, logError } from '@cloud-cli/cli';
2
2
  import { ProxyEntry, ProxyServer, ProxySettings } from '@cloud-cli/proxy';
3
3
  import { exec } from '@cloud-cli/exec';
4
4
  const defaultOptions = {
@@ -125,20 +125,17 @@ export class ProxyManager {
125
125
  const all = await this.getProxyListWithContainers();
126
126
  return all.filter((p) => p.domain.includes(options.domain));
127
127
  }
128
- async reload(options = {}) {
128
+ async restart() {
129
+ await px.reset();
130
+ await px.start();
131
+ await this.reload();
132
+ }
133
+ async reload() {
129
134
  const all = await this.getProxyListWithContainers();
130
- if (options.servers) {
131
- px.reset();
132
- }
133
- else {
134
- px.resetProxies();
135
- }
135
+ px.resetProxies();
136
136
  for (const t of all) {
137
137
  this.loadProxy(t);
138
138
  }
139
- if (options.servers) {
140
- px.start();
141
- }
142
139
  }
143
140
  loadProxy(t) {
144
141
  try {
@@ -154,9 +151,10 @@ export class ProxyManager {
154
151
  authorization: t.authorization,
155
152
  preserveHost: t.preserveHost,
156
153
  }));
154
+ logInfo(` ${t.domain} => ${t.target || t.redirectUrl}`);
157
155
  }
158
156
  catch (error) {
159
- console.log(`Error adding proxy for ${t.domain}:`, error);
157
+ logError(`Error adding proxy for ${t.domain}: ${error}`);
160
158
  }
161
159
  }
162
160
  async getRunningContainers() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-cli/px",
3
- "version": "4.4.3",
3
+ "version": "4.4.5",
4
4
  "description": "Reverse Proxy",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@cloud-cli/proxy": "^1.2.10",
31
+ "@cloud-cli/proxy": "^1.12.12",
32
32
  "@cloud-cli/exec": "^1.2.0"
33
33
  },
34
34
  "peerDependencies": {