Fix tunnels:list error handling; move ts-node to dependencies
This commit is contained in:
parent
07abc028aa
commit
580dbd4756
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue