Fix tunnels:list error handling; move ts-node to dependencies
This commit is contained in:
parent
07abc028aa
commit
580dbd4756
|
|
@ -196,8 +196,12 @@ function registerIPC(): void
|
||||||
ipcMain.handle( 'tunnels:list', async () =>
|
ipcMain.handle( 'tunnels:list', async () =>
|
||||||
{
|
{
|
||||||
const res = await apiFetch( '/api/tunnels' );
|
const res = await apiFetch( '/api/tunnels' );
|
||||||
const tunnels = await res.json() as Array<Record<string, unknown>>;
|
const data = await res.json();
|
||||||
return tunnels.map( t => ( { ...t, agentActive: agents.get( t.id as string )?.isActive() ?? false } ) );
|
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
|
// Connect
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue