mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-20 17:09:25 +02:00
Extract feedback, analytics, and AI modules from mana-core-auth into standalone mana-analytics service (Hono + Bun, Port 3064). New service (services/mana-analytics/): - User feedback CRUD with voting - AI-powered feedback title generation via mana-llm - Simplified from DuckDB analytics to pure PostgreSQL - ~550 LOC Removed from mana-core-auth: - feedback/ module (6 files) - analytics/ module (4 files) - ai/ module (3 files) - db/schema/feedback.schema.ts mana-core-auth now contains ONLY pure auth: - Better Auth (JWT, Sessions, 2FA, Passkeys, OIDC, Magic Links) - Organizations/Guilds (membership management) - API Keys, Security, Me (GDPR), Health, Metrics - Ready for Phase 5: Hono rewrite Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
19 lines
470 B
TypeScript
19 lines
470 B
TypeScript
/**
|
|
* Database connection using Drizzle ORM + postgres.js
|
|
*/
|
|
|
|
import { drizzle } from 'drizzle-orm/postgres-js';
|
|
import postgres from 'postgres';
|
|
import * as schema from './schema/index';
|
|
|
|
let db: ReturnType<typeof drizzle<typeof schema>> | null = null;
|
|
|
|
export function getDb(databaseUrl: string) {
|
|
if (!db) {
|
|
const client = postgres(databaseUrl, { max: 10 });
|
|
db = drizzle(client, { schema });
|
|
}
|
|
return db;
|
|
}
|
|
|
|
export type Database = ReturnType<typeof getDb>;
|