From 8deff327726501714d3347bab542c10ac81a9b9b Mon Sep 17 00:00:00 2001
From: Cory Dransfeldt <coryd@hey.com>
Date: Wed, 3 Apr 2024 20:44:06 -0700
Subject: [PATCH] chore: one less endpoint

---
 .env         |  3 +--
 api/music.js | 49 -------------------------------------------------
 2 files changed, 1 insertion(+), 51 deletions(-)
 delete mode 100644 api/music.js

diff --git a/.env b/.env
index 56ecc3fd..0f78cc71 100644
--- a/.env
+++ b/.env
@@ -9,5 +9,4 @@ API_TOKEN_READWISE=
 SECRET_FEED_ALBUM_RELEASES=
 COOKIE_STORYGRAPH=
 LISTENBRAINZ_TOKEN=
-ACCOUNT_ID_PLEX=
-API_KEY_MUSIC=
\ No newline at end of file
+ACCOUNT_ID_PLEX=
\ No newline at end of file
diff --git a/api/music.js b/api/music.js
deleted file mode 100644
index a63f52e4..00000000
--- a/api/music.js
+++ /dev/null
@@ -1,49 +0,0 @@
-import { getStore } from '@netlify/blobs'
-
-export default async (request) => {
-  const API_KEY_MUSIC = Netlify.env.get('API_KEY_MUSIC');
-  const params = new URL(request['url']).searchParams
-  const key = params.get('key')
-  const week = params.get('week')
-
-  if (!key) return new Response(JSON.stringify({
-      status: 'Bad request',
-    }),
-    { headers: { "Content-Type": "application/json" } }
-  )
-
-  if (key !== API_KEY_MUSIC) return new Response(JSON.stringify({
-      status: 'Forbidden',
-    }),
-    { headers: { "Content-Type": "application/json" } }
-  )
-
-  const scrobbles = getStore('scrobbles')
-  const scrobbleData = []
-  const artists = getStore('artists')
-  const albums = getStore('albums')
-  const artistsMap = await artists.get('artists-map', { type: 'json' })
-  const albumsMap = await albums.get('albums-map', { type: 'json' })
-  const nowPlaying = await scrobbles.get('now-playing', { type: 'json'})
-
-  if (week) {
-    const weekData = await scrobbles.get(week, { type: 'json'})
-    scrobbleData.push(...weekData['data'])
-  } else {
-    const windowData = await scrobbles.get('window', { type: 'json'})
-    scrobbleData.push(...windowData['data'])
-  }
-
-  return new Response(JSON.stringify({
-    scrobbles: scrobbleData,
-    nowPlaying,
-    artists: artistsMap,
-    albums: albumsMap
-  }),
-    { headers: { "Content-Type": "application/json" } }
-  )
-}
-
-export const config = {
-  path: '/api/music',
-}
\ No newline at end of file