refactor: rename planta → plants, clean up codebase

- Rename planta module to plants everywhere (routes, modules, API,
  branding, i18n, docker, docs, shared packages)
- Fix package name collisions: @mana/credits-service, @mana/subscriptions-service
  (unblocks turbo)
- Extract layout composables: use-ai-tier-items, use-sync-status-items,
  RouteTierGate (layout 1345→1015 lines)
- Create shared DB pool for apps/api (lib/db.ts), migrate 5 modules
- Add automations module queries.ts with useAllAutomations/useEnabledAutomations
- Remove debug console.log statements from production code
- Rename storage display name: Ablage → Speicher

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-12 18:59:44 +02:00
parent c6c19dbc77
commit a91a6076cc
110 changed files with 831 additions and 707 deletions

32
apps/api/src/lib/db.ts Normal file
View file

@ -0,0 +1,32 @@
/**
* Shared database connection pool for mana-api.
*
* All modules share a single connection pool instead of each creating
* their own. The pool is created lazily on first call and reused.
*
* Usage:
* ```ts
* import { getConnection } from '../../lib/db';
* import { drizzle } from 'drizzle-orm/postgres-js';
*
* const db = drizzle(getConnection(), { schema: { ... } });
* ```
*/
import postgres from 'postgres';
const DATABASE_URL =
process.env.DATABASE_URL ?? 'postgresql://mana:devpassword@localhost:5432/mana_platform';
let pool: ReturnType<typeof postgres> | null = null;
/**
* Returns the shared postgres connection pool.
* Created lazily with sensible defaults (max 10 connections).
*/
export function getConnection() {
if (!pool) {
pool = postgres(DATABASE_URL, { max: 10, idle_timeout: 30 });
}
return pool;
}