@gasket/plugin-https-proxy 7.3.8 → 7.3.10

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Create an HTTPS proxy server with Gasket to use as a sidecar for frameworks that
4
4
  do not handle HTTPS, such as Next.js. This can be useful for local development
5
- when you want to test HTTPS features and use secure cookies for
5
+ when you want to test HTTPS features and use secure cookies for
6
6
  authentication, etc.
7
7
  It can also be used in production if it is necessary for your application to
8
8
  handle HTTPS requests on the container.
@@ -102,8 +102,47 @@ import gasket from './gasket.js';
102
102
  gasket.actions.startProxyServer();
103
103
  ```
104
104
 
105
+
106
+ The complete flow is:
107
+
108
+ 1. Waits for `gasket.isReady` (ensuring async configuration is complete)
109
+ 2. Executes the `prebootHttpsProxy` lifecycle (one-time initialization)
110
+ 3. Executes the `httpsProxy` lifecycle for dynamic configuration
111
+ 4. Creates and starts the proxy server
105
112
  ## Lifecycles
106
113
 
114
+ ### prebootHttpsProxy
115
+
116
+ This lifecycle is executed before the proxy server is started. It is a good place to
117
+ execute operations that need to happen before the proxy server is started.
118
+
119
+ ```js
120
+ /**
121
+ * Executed before the proxy server is started.
122
+ *
123
+ * @param {Gasket} gasket Gasket API.
124
+ */
125
+ prebootHttpsProxy: async function prebootHttpsProxy(gasket) {
126
+ // async operations
127
+ }
128
+ ```
129
+
130
+ #### When to use `prebootHttpsProxy` vs `prepare`
131
+
132
+ The `preboot` lifecycle runs **once** when the proxy server starts, while the `prepare` lifecycle runs for **every** Gasket instance creation. Use `preboot` for:
133
+
134
+ - One-time proxy server initialization
135
+ - Setting up shared SSL/TLS contexts
136
+ - Loading certificates that will be reused across requests
137
+ - Establishing persistent connections or pools
138
+
139
+ Use `prepare` for:
140
+
141
+ - Per-instance configuration
142
+ - Setting up instance-specific state
143
+ - Operations that need fresh initialization for each Gasket instance
144
+
145
+ > **Note**: In SSR applications, new Gasket instances may be created for different contexts, causing `prepare` to run multiple times. For proxy servers, this can lead to unnecessary overhead. Use `preboot` for expensive initialization operations.
107
146
  ### httpsProxy
108
147
 
109
148
  While most settings can be configured in the `httpsProxy` configuration,
package/cjs/actions.js CHANGED
@@ -84,6 +84,7 @@ function startProxyServer(gasket) {
84
84
  function _startProxyServer() {
85
85
  _startProxyServer = _async_to_generator(function*(gasket) {
86
86
  yield gasket.isReady;
87
+ yield gasket.exec('prebootHttpsProxy');
87
88
  const { httpsProxy } = gasket.config;
88
89
  const { logger } = gasket;
89
90
  const opts = yield gasket.execWaterfall('httpsProxy', httpsProxy);
package/cjs/index.d.ts CHANGED
@@ -21,6 +21,7 @@ declare module '@gasket/core' {
21
21
  }
22
22
 
23
23
  export interface HookExecTypes {
24
+ prebootHttpsProxy(): MaybeAsync<void>;
24
25
  httpsProxy(proxyConfig: HttpsProxyConfig): MaybeAsync<HttpsProxyConfig>,
25
26
  }
26
27
 
package/cjs/index.js CHANGED
@@ -90,6 +90,11 @@ const _default = {
90
90
  }
91
91
  ],
92
92
  lifecycles: [
93
+ {
94
+ name: 'prebootHttpsProxy',
95
+ description: 'Executed before the proxy server is started.',
96
+ link: 'README.md#prebootHttpsProxy'
97
+ },
93
98
  {
94
99
  name: 'httpsProxy',
95
100
  method: 'execWaterfall',
package/lib/actions.js CHANGED
@@ -3,6 +3,7 @@ import proxy from 'http-proxy';
3
3
  /** @type {import('@gasket/core').ActionHandler<'startProxyServer'>} */
4
4
  export async function startProxyServer(gasket) {
5
5
  await gasket.isReady;
6
+ await gasket.exec('prebootHttpsProxy');
6
7
  const { httpsProxy } = gasket.config;
7
8
  const { logger } = gasket;
8
9
 
package/lib/index.d.ts CHANGED
@@ -21,6 +21,7 @@ declare module '@gasket/core' {
21
21
  }
22
22
 
23
23
  export interface HookExecTypes {
24
+ prebootHttpsProxy(): MaybeAsync<void>;
24
25
  httpsProxy(proxyConfig: HttpsProxyConfig): MaybeAsync<HttpsProxyConfig>,
25
26
  }
26
27
 
package/lib/index.js CHANGED
@@ -27,6 +27,11 @@ export default {
27
27
  }
28
28
  ],
29
29
  lifecycles: [
30
+ {
31
+ name: 'prebootHttpsProxy',
32
+ description: 'Executed before the proxy server is started.',
33
+ link: 'README.md#prebootHttpsProxy'
34
+ },
30
35
  {
31
36
  name: 'httpsProxy',
32
37
  method: 'execWaterfall',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gasket/plugin-https-proxy",
3
- "version": "7.3.8",
3
+ "version": "7.3.10",
4
4
  "description": "Adds support for running an https proxy",
5
5
  "type": "module",
6
6
  "types": "lib/index.d.ts",
@@ -46,11 +46,11 @@
46
46
  "eslint-plugin-unicorn": "^55.0.0",
47
47
  "typescript": "^5.8.2",
48
48
  "vitest": "^3.2.0",
49
- "@gasket/plugin-https": "7.3.5",
50
- "@gasket/plugin-metadata": "7.4.1",
51
- "create-gasket-app": "7.4.1",
52
49
  "@gasket/core": "7.5.0",
53
- "@gasket/plugin-logger": "7.3.4"
50
+ "@gasket/plugin-https": "7.3.6",
51
+ "@gasket/plugin-logger": "7.3.4",
52
+ "@gasket/plugin-metadata": "7.4.2",
53
+ "create-gasket-app": "7.4.4"
54
54
  },
55
55
  "eslintConfig": {
56
56
  "extends": [