mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 22:59:40 +02:00
Both apps are fully local-first via Dexie.js + mana-sync. Their NestJS backends were pure CRUD wrappers (20 + 31 source files) that are no longer needed. Changes: - Add packages/shared-hono: JWT auth via JWKS (jose), Drizzle DB factory, health route, generic GDPR admin handler, error middleware - Migrate zitare lists page from fetch() to listsStore (local-first) - Rewrite clock timers store from API-based to timerCollection (Dexie) - Update clock +layout.svelte CommandBar search to use local collections - Remove zitare-backend + clock-backend from docker-compose, CI/CD, Prometheus, env generation, setup scripts - Add docs/TECHNOLOGY_AUDIT_2026_03.md with full repo analysis Net result: -2 Docker containers, -2 ports, -2728 lines of code Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47 lines
944 B
TypeScript
47 lines
944 B
TypeScript
/**
|
|
* Error handling middleware for Hono servers.
|
|
*
|
|
* Catches unhandled errors and returns consistent JSON responses.
|
|
*/
|
|
|
|
import type { Context } from 'hono';
|
|
import { HTTPException } from 'hono/http-exception';
|
|
|
|
/**
|
|
* Global error handler — register with `app.onError(errorHandler)`.
|
|
*
|
|
* Usage:
|
|
* ```ts
|
|
* import { errorHandler } from '@manacore/shared-hono/error';
|
|
* const app = new Hono();
|
|
* app.onError(errorHandler);
|
|
* ```
|
|
*/
|
|
export function errorHandler(err: Error, c: Context) {
|
|
if (err instanceof HTTPException) {
|
|
return c.json(
|
|
{
|
|
error: err.message,
|
|
status: err.status,
|
|
},
|
|
err.status
|
|
);
|
|
}
|
|
|
|
console.error('[error]', err);
|
|
|
|
return c.json(
|
|
{
|
|
error: 'Internal server error',
|
|
status: 500,
|
|
},
|
|
500
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Not-found handler — register with `app.notFound(notFoundHandler)`.
|
|
*/
|
|
export function notFoundHandler(c: Context) {
|
|
return c.json({ error: 'Not found', status: 404 }, 404);
|
|
}
|