mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 01:35:39 -04:00
Rename TMDB_API_KEY to TMDB_API_READ_ACCESS_TOKEN and add optional base URL overrides
Renames the env var for clarity since it holds a read access token, not an API key. Adds optional TMDB_API_BASE_URL and TMDB_IMAGE_BASE_URL env vars for advanced users. Centralizes image URL construction into a shared tmdbImageUrl() helper, replacing hardcoded URLs across all components. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -4,5 +4,5 @@
|
||||
*/
|
||||
|
||||
export function isTmdbConfigured(): boolean {
|
||||
return !!process.env.TMDB_API_KEY;
|
||||
return !!process.env.TMDB_API_READ_ACCESS_TOKEN;
|
||||
}
|
||||
|
||||
+5
-8
@@ -7,11 +7,11 @@ import type {
|
||||
TmdbWatchProviderResponse,
|
||||
} from "./types";
|
||||
|
||||
const BASE_URL = "https://api.themoviedb.org/3";
|
||||
|
||||
const BASE_URL =
|
||||
process.env.TMDB_API_BASE_URL || "https://api.themoviedb.org/3";
|
||||
function getApiKey() {
|
||||
const key = process.env.TMDB_API_KEY;
|
||||
if (!key) throw new Error("TMDB_API_KEY is not set");
|
||||
const key = process.env.TMDB_API_READ_ACCESS_TOKEN;
|
||||
if (!key) throw new Error("TMDB_API_READ_ACCESS_TOKEN is not set");
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,4 @@ export async function getSimilar(tmdbId: number, type: "movie" | "tv") {
|
||||
return tmdbFetch<TmdbRecommendationResponse>(`/${type}/${tmdbId}/similar`);
|
||||
}
|
||||
|
||||
export function tmdbImageUrl(path: string | null, size = "w500") {
|
||||
if (!path) return null;
|
||||
return `https://image.tmdb.org/t/p/${size}${path}`;
|
||||
}
|
||||
export { tmdbImageUrl } from "./image";
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
const IMAGE_BASE_URL =
|
||||
process.env.TMDB_IMAGE_BASE_URL || "https://image.tmdb.org/t/p";
|
||||
|
||||
export function tmdbImageUrl(path: string | null, size = "w500") {
|
||||
if (!path) return null;
|
||||
return `${IMAGE_BASE_URL}/${size}${path}`;
|
||||
}
|
||||
Reference in New Issue
Block a user