Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/client/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ function App() {
);
}

// @ts-ignore
// @ts-expect-error
render(<App />, document.getElementById('app'));
4 changes: 2 additions & 2 deletions src/encryption.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
25 changes: 18 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -216,13 +218,22 @@ const app = new Elysia(serverConfig.elysia)
)

// Health check endpoint
.get('/ping', (): Static<typeof pingResponseSchema> => ({ status: 'ok', message: 'SparkHub is running' }), {
response: pingResponseSchema,
detail: {
summary: 'Health check',
description: 'Returns the status of the service',
},
})
.get(
'/ping',
(): Static<typeof pingResponseSchema> => ({
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'))
Expand Down
12 changes: 4 additions & 8 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading