@getpaseo/relay 0.1.105 → 0.1.106

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.
@@ -22,6 +22,7 @@ interface DurableObjectState {
22
22
  }
23
23
  interface Env {
24
24
  RELAY: DurableObjectNamespace;
25
+ PASEO_RELAY_UPSTREAM?: string;
25
26
  }
26
27
  interface DurableObjectNamespace {
27
28
  idFromName(name: string): DurableObjectId;
@@ -16,6 +16,7 @@
16
16
  * }
17
17
  * ```
18
18
  */
19
+ import { createCutoverProxy } from "./cutover-proxy.js";
19
20
  const LEGACY_RELAY_VERSION = "1";
20
21
  const CURRENT_RELAY_VERSION = "2";
21
22
  function resolveRelayVersion(rawValue) {
@@ -469,6 +470,9 @@ export class RelayDurableObject {
469
470
  */
470
471
  export default {
471
472
  async fetch(request, env) {
473
+ if (env.PASEO_RELAY_UPSTREAM) {
474
+ return createCutoverProxy(env.PASEO_RELAY_UPSTREAM).fetch(request);
475
+ }
472
476
  const url = new URL(request.url);
473
477
  // Health check
474
478
  if (url.pathname === "/health") {
@@ -0,0 +1,6 @@
1
+ interface CutoverProxy {
2
+ fetch(request: Request): Promise<Response>;
3
+ }
4
+ export declare function createCutoverProxy(origin: string): CutoverProxy;
5
+ export {};
6
+ //# sourceMappingURL=cutover-proxy.d.ts.map
@@ -0,0 +1,12 @@
1
+ export function createCutoverProxy(origin) {
2
+ const originUrl = new URL(origin);
3
+ return {
4
+ async fetch(request) {
5
+ const upstreamUrl = new URL(request.url);
6
+ upstreamUrl.protocol = originUrl.protocol;
7
+ upstreamUrl.host = originUrl.host;
8
+ return fetch(new Request(upstreamUrl, request));
9
+ },
10
+ };
11
+ }
12
+ //# sourceMappingURL=cutover-proxy.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/relay",
3
- "version": "0.1.105",
3
+ "version": "0.1.106",
4
4
  "description": "Paseo relay for bridging daemon and client connections",
5
5
  "files": [
6
6
  "dist",