Switch to main #1

Merged
jdf2 merged 28 commits from prod into main 2025-04-26 21:04:34 +00:00
Showing only changes of commit 486bf7cce7 - Show all commits

5
dist/start.js vendored
View File

@ -34,9 +34,11 @@ const apiCache = {
};
app.get("/getMostRecentSpotifyTrack", async function (req, res) {
console.log(apiCache.get("getMostRecentSpotifyTrack"));
if (apiCache.get("getMostRecentSpotifyTrack")) {
res.send(JSON.stringify(apiCache.get("getMostRecentSpotifyTrack")));
} else {
console.log("new")
const lastfmResponse = await fetch(
`http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=jdf221&api_key=${process.env.LASTFM_API_KEY}&format=json`
).then((res) => res.json());
@ -49,13 +51,14 @@ app.get("/getMostRecentSpotifyTrack", async function (req, res) {
const track = lastfmResponse?.["recenttracks"]?.["track"]?.[0];
response.track = track?.name;
response.artist = track?.artist?.["#text"];
console.log(response)
apiCache.set("getMostRecentSpotifyTrack", response);
res.send(JSON.stringify(response));
}
});
app.listen(3000);`2`
app.listen(3000);
async function getSpotifyApi() {
return {