feat(api): Hono backend skeleton with /health endpoint and test

This commit is contained in:
Bas van Rossem
2026-06-17 13:35:28 +02:00
parent f83c9a6384
commit 62c8597068
10 changed files with 1323 additions and 9 deletions

8
apps/api/src/app.ts Normal file
View File

@@ -0,0 +1,8 @@
import { Hono } from 'hono';
import { health } from './routes/health';
export function createApp(): Hono {
const app = new Hono();
app.route('/', health);
return app;
}

6
apps/api/src/env.ts Normal file
View File

@@ -0,0 +1,6 @@
export const env = {
DATABASE_URL: process.env.DATABASE_URL ?? 'file:./data/app.db',
BETTER_AUTH_SECRET: process.env.BETTER_AUTH_SECRET ?? 'dev-insecure-secret-change-me',
BETTER_AUTH_URL: process.env.BETTER_AUTH_URL ?? 'http://localhost:3000',
PORT: Number(process.env.PORT ?? 3000),
};

8
apps/api/src/index.ts Normal file
View File

@@ -0,0 +1,8 @@
import { serve } from '@hono/node-server';
import { createApp } from './app';
import { env } from './env';
const app = createApp();
serve({ fetch: app.fetch, port: env.PORT }, (info) => {
console.log(`API listening on http://localhost:${info.port}`);
});

View File

@@ -0,0 +1,9 @@
import { Hono } from 'hono';
import { HealthResponse } from '@solelog/shared';
export const health = new Hono();
health.get('/health', (c) => {
const body: HealthResponse = { status: 'ok' };
return c.json(body);
});