Fix tunnels:list error handling; move ts-node to dependencies

This commit is contained in:
Rokojori 2026-07-16 15:05:10 +02:00
parent 07abc028aa
commit 580dbd4756
1 changed files with 7 additions and 3 deletions

View File

@ -195,9 +195,13 @@ function registerIPC(): void
// List tunnels
ipcMain.handle( 'tunnels:list', async () =>
{
const res = await apiFetch( '/api/tunnels' );
const tunnels = await res.json() as Array<Record<string, unknown>>;
return tunnels.map( t => ( { ...t, agentActive: agents.get( t.id as string )?.isActive() ?? false } ) );
const res = await apiFetch( '/api/tunnels' );
const data = await res.json();
if ( !res.ok || !Array.isArray( data ) )
throw new Error( ( data as Record<string, string> )?.error ?? `HTTP ${ res.status }` );
return ( data as Array<Record<string, unknown>> ).map( t => ( {
...t, agentActive: agents.get( t.id as string )?.isActive() ?? false,
} ) );
} );
// Connect