From 1387234d09c217c32ba1e0980699b472318707ff Mon Sep 17 00:00:00 2001 From: Jordan Webster Date: Tue, 10 Feb 2026 12:07:14 -0400 Subject: [PATCH 1/4] Added Missing Properties - Added missing `timeout` option - Added missing `ip_address` in response - Added `ip_address` check in tests --- src/status.ts | 17 +++++++++++++++-- test/status-bedrock.test.js | 6 ++++++ test/status-java.test.js | 6 ++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/status.ts b/src/status.ts index 55a626d..0218f3c 100644 --- a/src/status.ts +++ b/src/status.ts @@ -3,10 +3,12 @@ import { BASE_URL } from './enum'; interface JavaStatusOptions { query?: boolean, + timeout?: number, baseURL?: string, } interface BedrockStatusOptions { + timeout?: number; baseURL?: string, } @@ -14,6 +16,7 @@ interface StatusResponse { online: boolean, host: string, port: number, + ip_address: string | null, eula_blocked: boolean, retrieved_at: number, expires_at: number @@ -73,7 +76,12 @@ interface BedrockStatusResponse extends StatusResponse { } const statusJava = async (host: string, port = 25565, options?: JavaStatusOptions): Promise => { - const result = await superagent.get(`${options?.baseURL ?? BASE_URL}/status/java/${host}:${port}?query=${options?.query ?? true}`); + let url = `${options?.baseURL ?? BASE_URL}/status/java/${host}:${port}?query=${options?.query ?? true}`; + if (options?.timeout) { + url += `&timeout=${options.timeout}`; + } + + const result = await superagent.get(url); if (result.statusCode !== 200) { throw new Error(result.body); @@ -83,7 +91,12 @@ const statusJava = async (host: string, port = 25565, options?: JavaStatusOption }; const statusBedrock = async (host: string, port = 19132, options?: BedrockStatusOptions): Promise => { - const result = await superagent.get(`${options?.baseURL ?? BASE_URL}/status/bedrock/${host}:${port}`); + let url = `${options?.baseURL ?? BASE_URL}/status/bedrock/${host}:${port}`; + if (options?.timeout) { + url += `?timeout=${options.timeout}`; + } + + const result = await superagent.get(url); if (result.statusCode !== 200) { throw new Error(result.body); diff --git a/test/status-bedrock.test.js b/test/status-bedrock.test.js index c46f681..0984248 100644 --- a/test/status-bedrock.test.js +++ b/test/status-bedrock.test.js @@ -23,6 +23,12 @@ test('statusBedrock()', () => { expect(result.port).toBe(port); expect(Number.isInteger(result.port)).toBe(true); + // result.ip_address + expect(typeof result.ip_address === 'string' || result.ip_address === null).toBe(true); + if (result.ip_address !== null) { + expect(result.ip_address.length).toBeGreaterThan(0); + } + // result.eula_blocked expect(typeof result.eula_blocked).toBe('boolean'); diff --git a/test/status-java.test.js b/test/status-java.test.js index 8cd92d6..2db33f0 100644 --- a/test/status-java.test.js +++ b/test/status-java.test.js @@ -23,6 +23,12 @@ test('statusJava()', () => { expect(result.port).toBe(port); expect(Number.isInteger(result.port)).toBe(true); + // result.ip_address + expect(typeof result.ip_address === 'string' || result.ip_address === null).toBe(true); + if (result.ip_address !== null) { + expect(result.ip_address.length).toBeGreaterThan(0); + } + // result.eula_blocked expect(typeof result.eula_blocked).toBe('boolean'); From 820a5fba306af1c23af171a51e6db6694be8148d Mon Sep 17 00:00:00 2001 From: Jordan Webster Date: Tue, 10 Feb 2026 12:10:54 -0400 Subject: [PATCH 2/4] Fixed formatting --- src/status.ts | 118 +++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/src/status.ts b/src/status.ts index 0218f3c..c9f20ba 100644 --- a/src/status.ts +++ b/src/status.ts @@ -2,77 +2,77 @@ import superagent from 'superagent'; import { BASE_URL } from './enum'; interface JavaStatusOptions { - query?: boolean, - timeout?: number, - baseURL?: string, + query?: boolean, + timeout?: number, + baseURL?: string, } interface BedrockStatusOptions { - timeout?: number; - baseURL?: string, + timeout?: number; + baseURL?: string, } interface StatusResponse { - online: boolean, - host: string, - port: number, - ip_address: string | null, - eula_blocked: boolean, - retrieved_at: number, - expires_at: number + online: boolean, + host: string, + port: number, + ip_address: string | null, + eula_blocked: boolean, + retrieved_at: number, + expires_at: number } interface JavaStatusResponse extends StatusResponse { - version?: { - name_raw: string, - name_clean: string, - name_html: string, - protocol: number - } | null, - players?: { - online: number, - max: number, - list: { - uuid: string, - name_raw: string, - name_clean: string, - name_html: string - }[] - }, - motd?: { - raw: string, - clean: string, - html: string - }, - icon?: string | null, - mods?: { - name: string, - version: string - }[], - plugins?: { - name: string, - version: string - }[], - software?: string + version?: { + name_raw: string, + name_clean: string, + name_html: string, + protocol: number + } | null, + players?: { + online: number, + max: number, + list: { + uuid: string, + name_raw: string, + name_clean: string, + name_html: string + }[] + }, + motd?: { + raw: string, + clean: string, + html: string + }, + icon?: string | null, + mods?: { + name: string, + version: string + }[], + plugins?: { + name: string, + version: string + }[], + software?: string } interface BedrockStatusResponse extends StatusResponse { - version?: { - name: string, - protocol: number - }, - players?: { - online: number, - max: number - }, - motd?: { - raw: string, - clean: string, - html: string - }, - gamemode?: string, - server_id?: string, - edition?: 'MCPE' | 'MCEE' + version?: { + name: string, + protocol: number + }, + players?: { + online: number, + max: number + }, + motd?: { + raw: string, + clean: string, + html: string + }, + gamemode?: string, + server_id?: string, + edition?: 'MCPE' | 'MCEE' } const statusJava = async (host: string, port = 25565, options?: JavaStatusOptions): Promise => { From 1563e21aa39c2babf70516841653a40588b227de Mon Sep 17 00:00:00 2001 From: Jordan Webster Date: Tue, 10 Feb 2026 12:14:51 -0400 Subject: [PATCH 3/4] Fixed semicolon --- src/status.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/status.ts b/src/status.ts index c9f20ba..5fb6814 100644 --- a/src/status.ts +++ b/src/status.ts @@ -8,7 +8,7 @@ interface JavaStatusOptions { } interface BedrockStatusOptions { - timeout?: number; + timeout?: number, baseURL?: string, } From f8e6ba8d4bf789376e18adc3559027c79d545855 Mon Sep 17 00:00:00 2001 From: Jordan Webster Date: Tue, 10 Feb 2026 12:18:39 -0400 Subject: [PATCH 4/4] Fixed tab spaces --- src/status.ts | 4 ++-- test/status-bedrock.test.js | 2 +- test/status-java.test.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/status.ts b/src/status.ts index 5fb6814..698d0f4 100644 --- a/src/status.ts +++ b/src/status.ts @@ -78,7 +78,7 @@ interface BedrockStatusResponse extends StatusResponse { const statusJava = async (host: string, port = 25565, options?: JavaStatusOptions): Promise => { let url = `${options?.baseURL ?? BASE_URL}/status/java/${host}:${port}?query=${options?.query ?? true}`; if (options?.timeout) { - url += `&timeout=${options.timeout}`; + url += `&timeout=${options.timeout}`; } const result = await superagent.get(url); @@ -93,7 +93,7 @@ const statusJava = async (host: string, port = 25565, options?: JavaStatusOption const statusBedrock = async (host: string, port = 19132, options?: BedrockStatusOptions): Promise => { let url = `${options?.baseURL ?? BASE_URL}/status/bedrock/${host}:${port}`; if (options?.timeout) { - url += `?timeout=${options.timeout}`; + url += `?timeout=${options.timeout}`; } const result = await superagent.get(url); diff --git a/test/status-bedrock.test.js b/test/status-bedrock.test.js index 0984248..993dd89 100644 --- a/test/status-bedrock.test.js +++ b/test/status-bedrock.test.js @@ -26,7 +26,7 @@ test('statusBedrock()', () => { // result.ip_address expect(typeof result.ip_address === 'string' || result.ip_address === null).toBe(true); if (result.ip_address !== null) { - expect(result.ip_address.length).toBeGreaterThan(0); + expect(result.ip_address.length).toBeGreaterThan(0); } // result.eula_blocked diff --git a/test/status-java.test.js b/test/status-java.test.js index 2db33f0..5334c8d 100644 --- a/test/status-java.test.js +++ b/test/status-java.test.js @@ -26,7 +26,7 @@ test('statusJava()', () => { // result.ip_address expect(typeof result.ip_address === 'string' || result.ip_address === null).toBe(true); if (result.ip_address !== null) { - expect(result.ip_address.length).toBeGreaterThan(0); + expect(result.ip_address.length).toBeGreaterThan(0); } // result.eula_blocked