@cloud-cli/px 3.4.3 → 3.5.1
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/proxy-manager.d.ts +7 -2
- package/dist/proxy-manager.js +6 -6
- package/dist/proxy.js +1 -1
- package/package.json +1 -1
package/dist/proxy-manager.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ProxyEntry } from './proxy.js';
|
|
2
2
|
export interface Domain {
|
|
3
3
|
domain: string;
|
|
4
|
+
host?: string;
|
|
4
5
|
}
|
|
5
6
|
export interface DomainAndTarget extends Domain {
|
|
6
7
|
target: string;
|
|
@@ -12,8 +13,12 @@ type ClassProperties<T> = {
|
|
|
12
13
|
[K in KeysOf<T>]: T[K] extends never ? never : T[K];
|
|
13
14
|
};
|
|
14
15
|
export declare class ProxyManager {
|
|
15
|
-
addProxy(proxy: ClassProperties<ProxyEntry>
|
|
16
|
-
|
|
16
|
+
addProxy(proxy: ClassProperties<ProxyEntry> & {
|
|
17
|
+
host?: string;
|
|
18
|
+
}): Promise<unknown>;
|
|
19
|
+
updateProxy(options: ClassProperties<ProxyEntry> & {
|
|
20
|
+
host?: string;
|
|
21
|
+
}): Promise<boolean>;
|
|
17
22
|
removeProxy(options: DomainAndTarget): Promise<unknown>;
|
|
18
23
|
getDomainList(): Promise<string[]>;
|
|
19
24
|
getProxyList(): Promise<ProxyEntry[]>;
|
package/dist/proxy-manager.js
CHANGED
|
@@ -5,14 +5,14 @@ const targetNotSpecifiedError = new Error('Target not specified');
|
|
|
5
5
|
export class ProxyManager {
|
|
6
6
|
addProxy(proxy) {
|
|
7
7
|
return new Promise(async (resolve, reject) => {
|
|
8
|
-
if (!proxy.domain) {
|
|
8
|
+
if (!proxy.domain && !proxy.host) {
|
|
9
9
|
return reject(domainNotSpecifiedError);
|
|
10
10
|
}
|
|
11
11
|
if (!proxy.target && !proxy.redirectUrl) {
|
|
12
12
|
return reject(targetNotSpecifiedError);
|
|
13
13
|
}
|
|
14
14
|
const entry = new ProxyEntry({
|
|
15
|
-
domain: proxy.domain,
|
|
15
|
+
domain: proxy.domain || proxy.host,
|
|
16
16
|
target: proxy.target,
|
|
17
17
|
cors: !!proxy.cors,
|
|
18
18
|
redirect: !!proxy.redirect,
|
|
@@ -29,7 +29,7 @@ export class ProxyManager {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
async updateProxy(options) {
|
|
32
|
-
const query = new Query().where('domain').is(options.domain);
|
|
32
|
+
const query = new Query().where('domain').is(options.domain || options.host);
|
|
33
33
|
const proxies = await Resource.find(ProxyEntry, query);
|
|
34
34
|
if (!proxies.length) {
|
|
35
35
|
return false;
|
|
@@ -42,10 +42,10 @@ export class ProxyManager {
|
|
|
42
42
|
}
|
|
43
43
|
removeProxy(options) {
|
|
44
44
|
return new Promise(async (resolve, reject) => {
|
|
45
|
-
if (!options.domain) {
|
|
45
|
+
if (!options.domain && !options.host) {
|
|
46
46
|
return reject(domainNotSpecifiedError);
|
|
47
47
|
}
|
|
48
|
-
const query = new Query().where('domain').is(options.domain);
|
|
48
|
+
const query = new Query().where('domain').is(options.domain || options.host);
|
|
49
49
|
if (options.target) {
|
|
50
50
|
query.where('target').is(options.target);
|
|
51
51
|
}
|
|
@@ -69,6 +69,6 @@ export class ProxyManager {
|
|
|
69
69
|
return Resource.find(ProxyEntry, new Query());
|
|
70
70
|
}
|
|
71
71
|
getProxyListForDomain(options) {
|
|
72
|
-
return Resource.find(ProxyEntry, new Query().where('domain').is(options.domain));
|
|
72
|
+
return Resource.find(ProxyEntry, new Query().where('domain').is(options.domain || options.host));
|
|
73
73
|
}
|
|
74
74
|
}
|
package/dist/proxy.js
CHANGED
|
@@ -179,7 +179,7 @@ export class ProxyServer {
|
|
|
179
179
|
}
|
|
180
180
|
handleError(error, res) {
|
|
181
181
|
console.error(error);
|
|
182
|
-
if (error.code === 'ECONNREFUSED') {
|
|
182
|
+
if (error.code === 'ECONNREFUSED' || error.code === 'ECONNRESET') {
|
|
183
183
|
res.writeHead(502);
|
|
184
184
|
res.end();
|
|
185
185
|
return;
|