mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 17:56:34 +00:00
fix(db): clean config field names under db: object
Removed redundant pg prefix — fields already nested under db:. pgHost→host, pgPort→port, pgDatabase→database, pgUser→user, pgPassword→password, pgPoolMax→poolMax, pgUrl→url. Updated all 3 plugin schemas, shared DbConfig type, init.ts, and sec-config template. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6ec2dcbec4
commit
2e88d891e1
6 changed files with 58 additions and 58 deletions
|
|
@ -26,12 +26,12 @@ default:
|
|||
db:
|
||||
driver: ${BF_DB_DRIVER}
|
||||
sqlitePath: /var/lib/betterframe/betterframe.db
|
||||
pgHost: ${BF_PG_HOST}
|
||||
pgPort: ${BF_PG_PORT}
|
||||
pgDatabase: ${BF_PG_DB}
|
||||
pgUser: ${BF_PG_USER}
|
||||
pgPassword: ${BF_PG_PASSWORD}
|
||||
pgPoolMax: ${BF_PG_POOL_MAX}
|
||||
host: ${BF_PG_HOST}
|
||||
port: ${BF_PG_PORT}
|
||||
database: ${BF_PG_DB}
|
||||
user: ${BF_PG_USER}
|
||||
password: ${BF_PG_PASSWORD}
|
||||
poolMax: ${BF_PG_POOL_MAX}
|
||||
host: 0.0.0.0
|
||||
port: 18080
|
||||
dataDir: /var/lib/betterframe
|
||||
|
|
@ -59,12 +59,12 @@ default:
|
|||
db:
|
||||
driver: ${BF_DB_DRIVER}
|
||||
sqlitePath: /var/lib/betterframe/betterframe.db
|
||||
pgHost: ${BF_PG_HOST}
|
||||
pgPort: ${BF_PG_PORT}
|
||||
pgDatabase: ${BF_PG_DB}
|
||||
pgUser: ${BF_PG_USER}
|
||||
pgPassword: ${BF_PG_PASSWORD}
|
||||
pgPoolMax: ${BF_PG_POOL_MAX}
|
||||
host: ${BF_PG_HOST}
|
||||
port: ${BF_PG_PORT}
|
||||
database: ${BF_PG_DB}
|
||||
user: ${BF_PG_USER}
|
||||
password: ${BF_PG_PASSWORD}
|
||||
poolMax: ${BF_PG_POOL_MAX}
|
||||
host: 0.0.0.0
|
||||
port: 18081
|
||||
codeTtlSeconds: 600
|
||||
|
|
@ -88,12 +88,12 @@ default:
|
|||
db:
|
||||
driver: ${BF_DB_DRIVER}
|
||||
sqlitePath: /var/lib/betterframe/betterframe.db
|
||||
pgHost: ${BF_PG_HOST}
|
||||
pgPort: ${BF_PG_PORT}
|
||||
pgDatabase: ${BF_PG_DB}
|
||||
pgUser: ${BF_PG_USER}
|
||||
pgPassword: ${BF_PG_PASSWORD}
|
||||
pgPoolMax: ${BF_PG_POOL_MAX}
|
||||
host: ${BF_PG_HOST}
|
||||
port: ${BF_PG_PORT}
|
||||
database: ${BF_PG_DB}
|
||||
user: ${BF_PG_USER}
|
||||
password: ${BF_PG_PASSWORD}
|
||||
poolMax: ${BF_PG_POOL_MAX}
|
||||
host: 0.0.0.0
|
||||
port: 18082
|
||||
dataDir: /var/lib/betterframe
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@ const ConfigSchema = 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),
|
||||
url: av.string().default(""),
|
||||
host: av.string().default("postgres"),
|
||||
port: av.int().min(1).max(65535).default(5432),
|
||||
database: av.string().default("betterframe"),
|
||||
user: av.string().default("betterframe"),
|
||||
password: av.string().default("betterframe"),
|
||||
poolMax: av.int().min(1).max(1000).default(10),
|
||||
},
|
||||
{ unknownKeys: "strip" },
|
||||
),
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@ const ConfigSchema = 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),
|
||||
url: av.string().default(""),
|
||||
host: av.string().default("postgres"),
|
||||
port: av.int().min(1).max(65535).default(5432),
|
||||
database: av.string().default("betterframe"),
|
||||
user: av.string().default("betterframe"),
|
||||
password: av.string().default("betterframe"),
|
||||
poolMax: av.int().min(1).max(1000).default(10),
|
||||
},
|
||||
{ unknownKeys: "strip" },
|
||||
),
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ const ConfigSchema = 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),
|
||||
url: av.string().default(""),
|
||||
host: av.string().default("postgres"),
|
||||
port: av.int().min(1).max(65535).default(5432),
|
||||
database: av.string().default("betterframe"),
|
||||
user: av.string().default("betterframe"),
|
||||
password: av.string().default("betterframe"),
|
||||
poolMax: av.int().min(1).max(1000).default(10),
|
||||
},
|
||||
{ unknownKeys: "strip" },
|
||||
),
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ 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),
|
||||
url: av.string().default(""),
|
||||
host: av.string().default("postgres"),
|
||||
port: av.int().min(1).max(65535).default(5432),
|
||||
database: av.string().default("betterframe"),
|
||||
user: av.string().default("betterframe"),
|
||||
password: av.string().default("betterframe"),
|
||||
poolMax: av.int().min(1).max(1000).default(10),
|
||||
},
|
||||
{ unknownKeys: "strip" },
|
||||
);
|
||||
|
|
@ -18,11 +18,11 @@ export const dbConfigSchema = av.object(
|
|||
export type DbConfig = {
|
||||
driver: "sqlite" | "postgres";
|
||||
sqlitePath: string;
|
||||
pgUrl: string;
|
||||
pgHost: string;
|
||||
pgPort: number;
|
||||
pgDatabase: string;
|
||||
pgUser: string;
|
||||
pgPassword: string;
|
||||
pgPoolMax: number;
|
||||
url: string;
|
||||
host: string;
|
||||
port: number;
|
||||
database: string;
|
||||
user: string;
|
||||
password: string;
|
||||
poolMax: number;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,16 +26,16 @@ export async function initDb(
|
|||
const notify = notifyFn ?? (() => {});
|
||||
|
||||
if (driver === "postgres") {
|
||||
let pgUrl = config.pgUrl ?? "";
|
||||
let pgUrl = config.url ?? "";
|
||||
if (!pgUrl) {
|
||||
const u = encodeURIComponent(config.pgUser);
|
||||
const p = encodeURIComponent(config.pgPassword);
|
||||
pgUrl = `postgres://${u}:${p}@${config.pgHost}:${config.pgPort}/${config.pgDatabase}`;
|
||||
const u = encodeURIComponent(config.user);
|
||||
const p = encodeURIComponent(config.password);
|
||||
pgUrl = `postgres://${u}:${p}@${config.host}:${config.port}/${config.database}`;
|
||||
}
|
||||
log.info(`connecting to postgres at ${pgUrl.replace(/:[^:@]+@/, ":***@")}`);
|
||||
|
||||
const { PgAdapter } = await import("./pg-adapter.js");
|
||||
const adapter = new PgAdapter(pgUrl, config.pgPoolMax);
|
||||
const adapter = new PgAdapter(pgUrl, config.poolMax);
|
||||
|
||||
// Run PG migrations. Track version in schema_migrations table.
|
||||
const { TENANT_MIGRATIONS } = await import("./migrations-pg.js");
|
||||
|
|
|
|||
Loading…
Reference in a new issue