mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 12:39:39 +02:00
Replace NestJS framework with Hono + Bun, eliminating the last NestJS service from the stack. All business logic preserved: - CAS upload with SHA-256 dedup - BullMQ image processing (Sharp thumbnails/variants) - Matrix MXC URL import - EXIF extraction - File streaming/transforms - Prometheus metrics 23 NestJS files → 12 Hono files. Zero NestJS in the monorepo. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
627 B
TypeScript
28 lines
627 B
TypeScript
import { drizzle } from 'drizzle-orm/postgres-js';
|
|
import postgres from 'postgres';
|
|
import * as schema from './db/schema';
|
|
|
|
let connection: ReturnType<typeof postgres> | null = null;
|
|
let db: ReturnType<typeof drizzle> | null = null;
|
|
|
|
export function getDb(databaseUrl: string) {
|
|
if (!db) {
|
|
connection = postgres(databaseUrl, {
|
|
max: 10,
|
|
idle_timeout: 20,
|
|
connect_timeout: 10,
|
|
});
|
|
db = drizzle(connection, { schema });
|
|
}
|
|
return db;
|
|
}
|
|
|
|
export async function closeConnection() {
|
|
if (connection) {
|
|
await connection.end();
|
|
connection = null;
|
|
db = null;
|
|
}
|
|
}
|
|
|
|
export type Database = ReturnType<typeof getDb>;
|