chore: update music api

This commit is contained in:
Cory Dransfeldt 2024-03-30 20:15:00 -07:00
parent bc5bf79e5c
commit 1dd48ddf68
No known key found for this signature in database
2 changed files with 22 additions and 13 deletions

View file

@ -28,6 +28,11 @@ export default async (request) => {
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' })
if (weeksArr.length > 0) {
weeksArr.forEach(async (week) => {
const weekData = await scrobbles.get(week, { type: 'json'})
@ -41,7 +46,11 @@ export default async (request) => {
scrobbleData.push(...windowData['data'])
}
return new Response(JSON.stringify({ data: scrobbleData }),
return new Response(JSON.stringify({
scrobbles: scrobbleData,
artists: artistsMap,
albums: albumsMap
}),
{ headers: { "Content-Type": "application/json" } }
)
}