@stacksjs/rpx 0.3.1 → 0.4.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/start.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- import type { ProxySetupOptions, ReverseProxyOption, ReverseProxyOptions, SSLConfig } from './types';
1
+ import type { CleanupOptions, ProxySetupOptions, ReverseProxyConfigs, ReverseProxyOption, ReverseProxyOptions, SSLConfig, SingleReverseProxyConfig } from './types';
2
2
 
3
3
  declare const activeServers: Set<http.Server | https.Server>;
4
- export declare function cleanup(): Promise<void>;
4
+ export declare function cleanup(options?: CleanupOptions): Promise<void>;
5
5
  declare function loadSSLConfig(options: ReverseProxyOption): Promise<SSLConfig | null>;
6
6
  declare function isPortInUse(port: number, hostname: string, verbose?: boolean): Promise<boolean>;
7
7
  declare function findAvailablePort(startPort: number, hostname: string, verbose?: boolean): Promise<number>;
8
8
  declare function testConnection(hostname: string, port: number, verbose?: boolean): Promise<void>;
9
- export declare function startServer(options?: ReverseProxyOption): Promise<void>;
10
- declare function createProxyServer(from: string, to: string, fromPort: number, listenPort: number, hostname: string, sourceUrl: Pick<URL, 'hostname' | 'host'>, ssl: SSLConfig | null, verbose?: boolean,): Promise<void>;
9
+ export declare function startServer(options: SingleReverseProxyConfig): Promise<void>;
10
+ declare function createProxyServer(from: string, to: string, fromPort: number, listenPort: number, hostname: string, sourceUrl: Pick<URL, 'hostname' | 'host'>, ssl: SSLConfig | null, verbose?: boolean): Promise<void>;
11
11
  export declare function setupReverseProxy(options: ProxySetupOptions): Promise<void>;
12
12
  export declare function startHttpRedirectServer(verbose?: boolean): void;
13
- export declare function startProxy(options?: ReverseProxyOption): void;
14
- export declare function startProxies(options?: ReverseProxyOptions): void;
13
+ export declare function startProxy(options: ReverseProxyOption): void;
14
+ export declare function startProxies(options?: ReverseProxyOptions): Promise<void>;
15
+ declare function isMultiProxyConfig(options: ReverseProxyConfigs): options is MultiReverseProxyConfig;
package/dist/types.d.ts CHANGED
@@ -1,24 +1,67 @@
1
1
  import type { TlsConfig } from '@stacksjs/tlsx';
2
2
 
3
- export type { TlsConfig };
4
- export declare interface ReverseProxyConfig {
3
+ export type { TlsConfig }
4
+ export declare type CustomTlsConfig = Partial<Omit<TlsConfig, 'caCertPath' | 'certPath' | 'keyPath'>> &
5
+ Pick<TlsConfig, 'caCertPath' | 'certPath' | 'keyPath'>
6
+
7
+ export interface BaseReverseProxyConfig {
5
8
  from: string
6
9
  to: string
7
- https: boolean | TlsConfig
10
+ }
11
+
12
+ export interface CleanupOptions {
13
+ domains?: string[]
14
+ etcHostsCleanup?: boolean
15
+ verbose?: boolean
16
+ }
17
+
18
+ export interface SharedProxySettings {
19
+ https: boolean | CustomTlsConfig
8
20
  etcHostsCleanup: boolean
9
21
  verbose: boolean
22
+ _cachedSSLConfig?: SSLConfig | null
23
+ }
24
+
25
+ export interface SingleReverseProxyConfig extends BaseReverseProxyConfig, SharedProxySettings {}
26
+
27
+ export interface MultiReverseProxyConfig extends SharedProxySettings {
28
+ proxies: BaseReverseProxyConfig[]
10
29
  }
11
- export declare type ReverseProxyOption = Partial<ReverseProxyConfig>
12
- export type ReverseProxyOptions = ReverseProxyOption | ReverseProxyOption[]
13
- export declare interface SSLConfig {
30
+
31
+ export type ReverseProxyConfigs = SingleReverseProxyConfig | MultiReverseProxyConfig
32
+
33
+ export type BaseReverseProxyOption = Partial<BaseReverseProxyConfig>
34
+ export type PartialSharedSettings = Partial<SharedProxySettings>
35
+
36
+ export type MultiReverseProxyOption = MultiReverseProxyConfig
37
+
38
+ export type ReverseProxyOption = SingleReverseProxyConfig
39
+ export type ReverseProxyOptions = SingleReverseProxyConfig | MultiReverseProxyOption
40
+
41
+ export interface SSLConfig {
14
42
  key: string
15
43
  cert: string
16
44
  ca?: string | string[]
17
45
  }
18
- export declare interface ProxySetupOptions extends Omit<ReverseProxyOption, 'from'> {
46
+
47
+ export interface ProxySetupOptions extends Omit<ReverseProxyOption, 'from'> {
48
+ fromPort: number
49
+ sourceUrl: Pick<URL, 'hostname' | 'host'>
50
+ ssl: SSLConfig | null
51
+ from: string
52
+ to: string
53
+ }
54
+
55
+ export interface PortManager {
56
+ usedPorts: Set<number>
57
+ getNextAvailablePort: (startPort: number) => Promise<number>
58
+ }
59
+
60
+ export interface ProxySetupOptions extends Omit<ReverseProxyOption, 'from'> {
19
61
  fromPort: number
20
62
  sourceUrl: Pick<URL, 'hostname' | 'host'>
21
63
  ssl: SSLConfig | null
22
64
  from: string
23
65
  to: string
66
+ portManager?: PortManager
24
67
  }
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare function keyPath(): string;
2
- export declare function certPath(): string;
3
- export declare function caCertPath(): string;
4
- export declare function debugLog(category: string, message: string, verbose?: boolean): void;
1
+ import type { ReverseProxyConfigs } from './types';
2
+
3
+ export declare function debugLog(category: string, message: string, verbose?: boolean): void;
4
+ export declare function extractDomains(options: ReverseProxyConfigs): string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/rpx",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.4.1",
5
5
  "description": "A modern reverse proxy.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -61,16 +61,16 @@
61
61
  "preview:docs": "vitepress preview docs"
62
62
  },
63
63
  "dependencies": {
64
- "@stacksjs/tlsx": "^0.6.0"
64
+ "@stacksjs/tlsx": "^0.7.6"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@stacksjs/cli": "^0.68.2",
68
68
  "@stacksjs/eslint-config": "^3.8.1-beta.2",
69
69
  "@stacksjs/storage": "^0.68.2",
70
- "@types/bun": "^1.1.13",
71
- "bun-config": "^0.2.0",
72
- "bun-plugin-dtsx": "^0.21.8",
73
- "typescript": "^5.6.3",
70
+ "@types/bun": "^1.1.14",
71
+ "bun-config": "^0.3.2",
72
+ "bun-plugin-dtsx": "^0.21.9",
73
+ "typescript": "^5.7.2",
74
74
  "vitepress": "^1.5.0"
75
75
  },
76
76
  "simple-git-hooks": {