feat(api): Hono backend skeleton with /health endpoint and test
This commit is contained in:
8
apps/api/src/app.ts
Normal file
8
apps/api/src/app.ts
Normal 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
6
apps/api/src/env.ts
Normal 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
8
apps/api/src/index.ts
Normal 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}`);
|
||||
});
|
||||
9
apps/api/src/routes/health.ts
Normal file
9
apps/api/src/routes/health.ts
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user