Extract shared constants into lib/constants.ts

- Add `lib/constants.ts` exporting `DATA_DIR`, `DATABASE_URL`, `CACHE_DIR`,
  `BACKUP_DIR`, `AVATAR_DIR`, `TMDB_API_BASE_URL`, and `TMDB_IMAGE_BASE_URL`
- Replace inline `process.env` derivations in `db/client`, `backup`,
  `image-cache`, `system-health`, `tmdb/client`, `actions/settings`,
  and `api/avatars` with imports from the new module
This commit is contained in:
2026-03-08 11:06:29 -04:00
parent 84c4356a9f
commit 17fe19e85b
8 changed files with 35 additions and 38 deletions
+1 -5
View File
@@ -1,7 +1,7 @@
import { Database } from "bun:sqlite";
import path from "node:path";
import type { Logger } from "drizzle-orm";
import { drizzle } from "drizzle-orm/bun-sqlite";
import { DATABASE_URL } from "@/lib/constants";
import { createLogger } from "@/lib/logger";
import * as schema from "./schema";
@@ -29,10 +29,6 @@ const globalForDb = globalThis as unknown as {
_client: Database | undefined;
};
const DATABASE_URL =
process.env.DATABASE_URL ||
path.join(process.env.DATA_DIR || "./data", "sqlite.db");
function getClient() {
if (!globalForDb._client) {
globalForDb._client = new Database(DATABASE_URL);