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
+2 -4
View File
@@ -1,3 +1,4 @@
import { TMDB_API_BASE_URL } from "@/lib/constants";
import { createLogger } from "@/lib/logger";
import type {
TmdbExternalIds,
@@ -18,9 +19,6 @@ import type {
} from "./types";
const log = createLogger("tmdb");
const BASE_URL =
process.env.TMDB_API_BASE_URL || "https://api.themoviedb.org/3";
function getApiKey() {
const key = process.env.TMDB_API_READ_ACCESS_TOKEN;
if (!key) throw new Error("TMDB_API_READ_ACCESS_TOKEN is not set");
@@ -32,7 +30,7 @@ async function tmdbFetch<T>(
params?: Record<string, string>,
fetchOptions?: RequestInit,
): Promise<T> {
const url = new URL(`${BASE_URL}${path}`);
const url = new URL(`${TMDB_API_BASE_URL}${path}`);
if (params) {
for (const [k, v] of Object.entries(params)) {
url.searchParams.set(k, v);