BetterFrame/server/src/shared/db/config.ts
Mitchell R 0479cb7b4b
refactor(db): move service-store from BSB plugin to shared/db library
Each service plugin now independently initializes its own DB connection
via shared/db/init.ts instead of depending on a central service-store
plugin. This removes the inter-plugin dependency ordering and the
plugin-registry singleton, making each service self-contained.

- Move db-adapter, repository, mappers, migrations, adapters to shared/db/
- Create shared/db/config.ts (reusable dbConfigSchema) and init.ts
- Delete service-store plugin and plugin-registry
- Add db config block to each service's ConfigSchema + sec-config template
- Move event_log purge timer into service-admin-http
- Update all import paths across shared modules and plugins

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-24 02:48:32 +02:00

28 lines
842 B
TypeScript

import * as av from "@anyvali/js";
export const dbConfigSchema = av.object(
{
driver: av.enum_(["sqlite", "postgres"] as const).default("postgres"),
sqlitePath: av.string().minLength(1).default("/var/lib/betterframe/betterframe.db"),
pgUrl: av.string().default(""),
pgHost: av.string().default("postgres"),
pgPort: av.int().min(1).max(65535).default(5432),
pgDatabase: av.string().default("betterframe"),
pgUser: av.string().default("betterframe"),
pgPassword: av.string().default("betterframe"),
pgPoolMax: av.int().min(1).max(1000).default(10),
},
{ unknownKeys: "strip" },
);
export type DbConfig = {
driver: "sqlite" | "postgres";
sqlitePath: string;
pgUrl: string;
pgHost: string;
pgPort: number;
pgDatabase: string;
pgUser: string;
pgPassword: string;
pgPoolMax: number;
};