From b13f5ac72b9d2e077a81f2e237fffd8eb09a84fc Mon Sep 17 00:00:00 2001 From: r1n04h Date: Wed, 20 May 2026 12:05:01 +0100 Subject: [PATCH 1/2] feat: better ping --- package.json | 2 +- src/index.ts | 25 ++++++++++++++++++------- test/index.test.ts | 7 +++++-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 08e3ede..9553fde 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "SparkHub", - "version": "1.3.0", + "version": "1.3.1", "scripts": { "test": "bun test", "dev": "bun run --watch src/index.ts", diff --git a/src/index.ts b/src/index.ts index 3f59097..15312a9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -106,6 +106,8 @@ const getOrCreateRequestId = (request: Request): string => { const pingResponseSchema = t.Object({ status: t.String(), message: t.String(), + version: t.String(), + uptime: t.Number(), }); const lnurlPayResponseSchema = t.Object({ @@ -216,13 +218,22 @@ const app = new Elysia(serverConfig.elysia) ) // Health check endpoint - .get('/ping', (): Static => ({ status: 'ok', message: 'SparkHub is running' }), { - response: pingResponseSchema, - detail: { - summary: 'Health check', - description: 'Returns the status of the service', - }, - }) + .get( + '/ping', + (): Static => ({ + status: 'ok', + message: 'SparkHub is running', + version: pckg.version, + uptime: process.uptime(), + }), + { + response: pingResponseSchema, + detail: { + summary: 'Health check', + description: 'Returns the status of the service', + }, + } + ) // Serve the frontend .get('/', () => Bun.file('public/index.html')) diff --git a/test/index.test.ts b/test/index.test.ts index 61b4579..9df8357 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -7,10 +7,13 @@ describe('Elysia', () => { .handle(new Request('http://localhost:3000/ping')) .then((res: Response) => res.json()) - expect(response).toEqual({ + expect(response).toMatchObject({ status: 'ok', - message: 'SparkHub is running' + message: 'SparkHub is running', + version: '1.3.0', }) + expect(response.uptime).toBeGreaterThanOrEqual(0) + expect(Number.isFinite(response.uptime)).toBe(true) }) describe('/api/users/:username', () => { From dfcd8cd52540264a107277711d850c07fd6c8af0 Mon Sep 17 00:00:00 2001 From: r1n04h Date: Wed, 20 May 2026 12:13:20 +0100 Subject: [PATCH 2/2] feat: better ping --- src/client/app.tsx | 2 +- src/encryption.ts | 4 ++-- test/index.test.ts | 15 ++++----------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/client/app.tsx b/src/client/app.tsx index 9133c03..8c2fbd3 100644 --- a/src/client/app.tsx +++ b/src/client/app.tsx @@ -21,5 +21,5 @@ function App() { ); } -// @ts-ignore +// @ts-expect-error render(, document.getElementById('app')); diff --git a/src/encryption.ts b/src/encryption.ts index 4b1959f..471cb55 100644 --- a/src/encryption.ts +++ b/src/encryption.ts @@ -1,7 +1,7 @@ import { scryptAsync } from '@noble/hashes/scrypt'; -// @ts-ignore dont want to install @types/browserify-cipher as it has incorrect definition of the func we use +// @ts-expect-error dont want to install @types/browserify-cipher as it has incorrect definition of the func we use import * as aes from 'browserify-cipher'; -// @ts-ignore its purejs, we donthave types for it +// @ts-expect-error its purejs, we donthave types for it import { hexToUint8Array, uint8ArrayToHex } from './uint8array-extras'; const createCipheriv = aes.createCipheriv; diff --git a/test/index.test.ts b/test/index.test.ts index 9df8357..9dac526 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -3,17 +3,10 @@ import { app } from '../src/index' describe('Elysia', () => { it('returns a response from /ping route', async () => { - const response = await app - .handle(new Request('http://localhost:3000/ping')) - .then((res: Response) => res.json()) - - expect(response).toMatchObject({ - status: 'ok', - message: 'SparkHub is running', - version: '1.3.0', - }) - expect(response.uptime).toBeGreaterThanOrEqual(0) - expect(Number.isFinite(response.uptime)).toBe(true) + const r = await app.handle(new Request('http://localhost:3000/ping')).then(res => res.json()) + expect(r).toMatchObject({ status: 'ok', message: 'SparkHub is running' }) + expect(r.version).toMatch(/^\d+\.\d+\.\d+/) + expect(r.uptime).toBeGreaterThanOrEqual(0) }) describe('/api/users/:username', () => {