diff --git a/src/cli/commands/perf.ts b/src/cli/commands/perf.ts index ae6d99a..58addb8 100644 --- a/src/cli/commands/perf.ts +++ b/src/cli/commands/perf.ts @@ -1,21 +1,17 @@ import color from 'ansis' -import { get, handleError, post } from '../http' +import { get, post } from '../http' export async function perfToggle(onOff?: string) { - try { - if (onOff && !['on', 'off', 'status'].includes(onOff)) { - console.error('Usage: toes perf [on|off|status]') - process.exit(1) - } - const res = onOff === 'status' - ? await get<{ perfTiming: boolean }>('/api/system/perf') - : await post<{ perfTiming: boolean }>('/api/system/perf', - onOff === 'on' ? { on: true } : onOff === 'off' ? { on: false } : {}) - if (res) { - const label = res.perfTiming ? color.green('on') : color.red('off') - console.log(`Perf timing ${onOff === 'status' ? 'is ' : ''}${label}`) - } - } catch (error) { - handleError(error) + if (onOff && !['on', 'off', 'status'].includes(onOff)) { + console.error('Usage: toes perf [on|off|status]') + process.exit(1) + } + const body = onOff && onOff !== 'status' ? { on: onOff === 'on' } : {} + const res = onOff === 'status' + ? await get<{ perfTiming: boolean }>('/api/system/perf') + : await post<{ perfTiming: boolean }>('/api/system/perf', body) + if (res) { + const label = res.perfTiming ? color.green('on') : color.red('off') + console.log(`Perf timing ${onOff === 'status' ? 'is ' : ''}${label}`) } } diff --git a/src/server/proxy.ts b/src/server/proxy.ts index 09d292e..9733480 100644 --- a/src/server/proxy.ts +++ b/src/server/proxy.ts @@ -1,10 +1,10 @@ import type { Server, ServerWebSocket } from 'bun' import { getAppBySubdomain } from '$apps' -export type { WsData } - export const perf = { timing: false } +export type { WsData } + const pendingMessages = new Map, (string | ArrayBuffer | Uint8Array)[]>() const upstreams = new Map, WebSocket>() @@ -55,14 +55,15 @@ export async function proxySubdomain(subdomain: string, req: Request): Promise