coalesce API key to remove linter warning

This commit is contained in:
Jonathan Barrow
2023-09-26 15:22:13 -04:00
parent 88b2e631f0
commit 147d2f3ea9

View File

@@ -41,7 +41,7 @@ type CommandLineArguments = {
url: string; url: string;
}; };
const TMDB_API_KEY = process.env.MOVIE_WEB_TMDB_API_KEY; const TMDB_API_KEY = process.env.MOVIE_WEB_TMDB_API_KEY ?? '';
if (!TMDB_API_KEY?.trim()) { if (!TMDB_API_KEY?.trim()) {
throw new Error('Missing MOVIE_WEB_TMDB_API_KEY environment variable'); throw new Error('Missing MOVIE_WEB_TMDB_API_KEY environment variable');
@@ -81,7 +81,7 @@ async function makeTMDBRequest(url: string): Promise<Response> {
// * JWT keys always start with ey and are ONLY valid as a header. // * JWT keys always start with ey and are ONLY valid as a header.
// * All other keys are ONLY valid as a query param. // * All other keys are ONLY valid as a query param.
// * Thanks TMDB. // * Thanks TMDB.
if (TMDB_API_KEY!.startsWith('ey')) { if (TMDB_API_KEY.startsWith('ey')) {
headers.authorization = `Bearer ${TMDB_API_KEY}`; headers.authorization = `Bearer ${TMDB_API_KEY}`;
} else { } else {
requestURL += `?api_key=${TMDB_API_KEY}`; requestURL += `?api_key=${TMDB_API_KEY}`;