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/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/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..9dac526 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -3,14 +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).toEqual({ - status: 'ok', - message: 'SparkHub is running' - }) + 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', () => {