mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-22 15:46:41 +02:00
refactor(infra): remove zitare + clock NestJS backends, add shared-hono package
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>
This commit is contained in:
parent
82de69476f
commit
32939fbfb5
81 changed files with 1236 additions and 2727 deletions
49
packages/shared-hono/src/db.ts
Normal file
49
packages/shared-hono/src/db.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* Drizzle ORM database connection factory for Hono servers.
|
||||
*
|
||||
* Provides a lightweight connection with sensible defaults.
|
||||
* Each server defines its own minimal schema (only tables it needs).
|
||||
*/
|
||||
|
||||
import { drizzle } from 'drizzle-orm/postgres-js';
|
||||
import postgres from 'postgres';
|
||||
|
||||
export interface DbOptions {
|
||||
/** PostgreSQL connection URL */
|
||||
url?: string;
|
||||
/** Max connections (default: 5) */
|
||||
maxConnections?: number;
|
||||
/** Idle timeout in seconds (default: 20) */
|
||||
idleTimeout?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Drizzle database instance with postgres.js driver.
|
||||
*
|
||||
* Usage:
|
||||
* ```ts
|
||||
* import { createDb } from '@manacore/shared-hono/db';
|
||||
* import { tasks, projects } from './schema';
|
||||
*
|
||||
* const db = createDb({
|
||||
* schema: { tasks, projects },
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function createDb<TSchema extends Record<string, unknown>>(
|
||||
opts?: DbOptions & { schema?: TSchema }
|
||||
) {
|
||||
const url =
|
||||
opts?.url ??
|
||||
process.env.DATABASE_URL ??
|
||||
'postgresql://manacore:devpassword@localhost:5432/mana';
|
||||
|
||||
const connection = postgres(url, {
|
||||
max: opts?.maxConnections ?? 5,
|
||||
idle_timeout: opts?.idleTimeout ?? 20,
|
||||
});
|
||||
|
||||
return drizzle(connection, {
|
||||
schema: opts?.schema as TSchema,
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue