mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 01:35:39 -04:00
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:
+2
-4
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user