refactor: unwrap ServerProxy namespace + self-reexport (#22969)
This commit is contained in:
@@ -101,15 +101,14 @@ const app = (upgrade: UpgradeWebSocket) =>
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
export namespace ServerProxy {
|
const log = Log.Default.clone().tag("service", "server-proxy")
|
||||||
const log = Log.Default.clone().tag("service", "server-proxy")
|
|
||||||
|
|
||||||
export async function http(
|
export async function http(
|
||||||
url: string | URL,
|
url: string | URL,
|
||||||
extra: HeadersInit | undefined,
|
extra: HeadersInit | undefined,
|
||||||
req: Request,
|
req: Request,
|
||||||
workspaceID: WorkspaceID,
|
workspaceID: WorkspaceID,
|
||||||
) {
|
) {
|
||||||
if (!Workspace.isSyncing(workspaceID)) {
|
if (!Workspace.isSyncing(workspaceID)) {
|
||||||
return new Response(`broken sync connection for workspace: ${workspaceID}`, {
|
return new Response(`broken sync connection for workspace: ${workspaceID}`, {
|
||||||
status: 503,
|
status: 503,
|
||||||
@@ -150,15 +149,15 @@ export namespace ServerProxy {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function websocket(
|
export function websocket(
|
||||||
upgrade: UpgradeWebSocket,
|
upgrade: UpgradeWebSocket,
|
||||||
target: string | URL,
|
target: string | URL,
|
||||||
extra: HeadersInit | undefined,
|
extra: HeadersInit | undefined,
|
||||||
req: Request,
|
req: Request,
|
||||||
env: unknown,
|
env: unknown,
|
||||||
) {
|
) {
|
||||||
const proxy = new URL(req.url)
|
const proxy = new URL(req.url)
|
||||||
proxy.pathname = "/__workspace_ws"
|
proxy.pathname = "/__workspace_ws"
|
||||||
proxy.search = ""
|
proxy.search = ""
|
||||||
@@ -179,5 +178,6 @@ export namespace ServerProxy {
|
|||||||
}),
|
}),
|
||||||
env as never,
|
env as never,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export * as ServerProxy from "./proxy"
|
||||||
|
|||||||
Reference in New Issue
Block a user