From e36098142253e5098e0fcf1f92b83ff23bb05395 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 1 Aug 2024 01:22:28 -0700 Subject: [PATCH] Add fallback for optional env variable --- src/routes/api/lastfm/+server.ts | 4 ++-- src/routes/api/steam/+server.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/api/lastfm/+server.ts b/src/routes/api/lastfm/+server.ts index 34c984c..5bced93 100644 --- a/src/routes/api/lastfm/+server.ts +++ b/src/routes/api/lastfm/+server.ts @@ -1,3 +1,4 @@ +import 'dotenv/config' import { LastClient } from '@musicorum/lastfm' import { searchItunes, @@ -14,7 +15,7 @@ const USERNAME = 'jedmund' const ALBUM_LIMIT = 3 export const GET: RequestHandler = async ({ url }) => { - const client = new LastClient(LASTFM_API_KEY) + const client = new LastClient(LASTFM_API_KEY || '') try { // const albums = await getWeeklyAlbumChart(client, USERNAME) @@ -94,7 +95,6 @@ async function searchItunesForAlbum(album: Album): Promise { if (itunesResult && itunesResult.results.length > 0) { const firstResult = itunesResult.results[0] - console.log(firstResult) album.images.itunes = firstResult.artworkUrl100.replace('100x100', '600x600') } diff --git a/src/routes/api/steam/+server.ts b/src/routes/api/steam/+server.ts index 2ca021a..a7bbc15 100644 --- a/src/routes/api/steam/+server.ts +++ b/src/routes/api/steam/+server.ts @@ -3,7 +3,7 @@ import type { RequestHandler } from './$types' import SteamAPI, { Game, GameInfo, GameInfoExtended, UserPlaytime } from 'steamapi' export const GET: RequestHandler = async ({ params }) => { - const steam = new SteamAPI(process.env.STEAM_API_KEY) + const steam = new SteamAPI(process.env.STEAM_API_KEY || '') try { const steamId = '76561197997279808'