chore(config): update speaches config and ignore sveltekit dashboard

- Simplified .env.example to use localhost SPEACHES_URL
- Removed unused prod_url from SpeachesSettings config
- Added dashboard node_modules and build dirs to .gitignore
- Streamlines local development setup
This commit is contained in:
2026-05-16 18:21:07 -04:00
parent ecf37658ce
commit dbdb03beb9
15 changed files with 2929 additions and 3 deletions

50
dashboard/src/lib/api.ts Normal file
View File

@@ -0,0 +1,50 @@
import type { CallSummary, DeviceStatus, GatewayEvent, GatewayStatus, HealthStatus } from './types';
async function get<T>(path: string): Promise<T> {
const res = await fetch(path);
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
return res.json() as Promise<T>;
}
export async function fetchGatewayStatus(): Promise<GatewayStatus> {
return get<GatewayStatus>('/');
}
export async function fetchHealth(): Promise<HealthStatus> {
return get<HealthStatus>('/health');
}
export async function fetchActiveCalls(): Promise<CallSummary[]> {
return get<CallSummary[]>('/api/calls/active');
}
export async function fetchDevices(): Promise<DeviceStatus[]> {
return get<DeviceStatus[]>('/api/devices');
}
export async function hangupCall(callId: string): Promise<void> {
const res = await fetch(`/api/calls/${callId}/hangup`, { method: 'POST' });
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
}
export function connectEventStream(
onEvent: (e: GatewayEvent) => void,
onClose: () => void,
): () => void {
const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
const ws = new WebSocket(`${proto}//${location.host}/ws/events`);
ws.onmessage = (msg) => {
try {
const event = JSON.parse(msg.data as string) as GatewayEvent;
onEvent(event);
} catch {
// malformed frame — ignore
}
};
ws.onclose = () => onClose();
ws.onerror = () => onClose();
return () => ws.close();
}