From 56fb79e041138468099a7d79ca5c3cf6b3eecd25 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Thu, 21 Mar 2024 00:08:18 -0400 Subject: [PATCH] fix(striker-ui-api): correct defaults in get host connection; patches #593 --- .../request_handlers/host/getHostConnection.ts | 15 +++++++++++++-- .../src/types/GetAnvilDataFunction.d.ts | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts b/striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts index ac47c2c0..5bcd2fd9 100644 --- a/striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts +++ b/striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts @@ -14,8 +14,19 @@ const buildHostConnections = ( }: { defaultPort?: number; defaultUser?: string } = {}, ) => Object.entries(databaseHash).reduce( - (previous, [hostUUID, { host: ipAddress, ping, port: rawPort, user }]) => { - const port = Number(rawPort); + ( + previous, + [ + hostUUID, + { + host: ipAddress, + ping, + port: rPort = defaultPort, + user = defaultUser, + }, + ], + ) => { + const port = Number(rPort); if (hostUUID === fromHostUUID) { previous.inbound.port = port; diff --git a/striker-ui-api/src/types/GetAnvilDataFunction.d.ts b/striker-ui-api/src/types/GetAnvilDataFunction.d.ts index 53433c40..1543f37c 100644 --- a/striker-ui-api/src/types/GetAnvilDataFunction.d.ts +++ b/striker-ui-api/src/types/GetAnvilDataFunction.d.ts @@ -25,11 +25,11 @@ type AnvilDataAnvilListHash = { type AnvilDataDatabaseHash = { [hostUUID: string]: { host: string; - name: string; + name?: string; password: string; ping: string; port: string; - user: string; + user?: string; }; };