Add fallback for optional env variable

This commit is contained in:
Justin Edmund 2024-08-01 01:22:28 -07:00
parent c6130aff93
commit e360981422
2 changed files with 3 additions and 3 deletions

View file

@ -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<Album> {
if (itunesResult && itunesResult.results.length > 0) {
const firstResult = itunesResult.results[0]
console.log(firstResult)
album.images.itunes = firstResult.artworkUrl100.replace('100x100', '600x600')
}

View file

@ -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'