clean up type declarations

This commit is contained in:
2021-06-13 08:24:27 -04:00
parent e692d07031
commit f35bd7aac2
15 changed files with 161 additions and 179 deletions
+1 -31
View File
@@ -1,4 +1,4 @@
"use strict";
/// <reference types="./types/tracks" />
// Fetches my Spotify most-played tracks or currently playing track.
// Heavily inspired by @leerob: https://leerob.io/snippets/spotify
@@ -17,31 +17,6 @@ const NOW_PLAYING_ENDPOINT = `https://api.spotify.com/v1/me/player/currently-pla
// https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-users-top-artists-and-tracks
const TOP_TRACKS_ENDPOINT = `https://api.spotify.com/v1/me/top/tracks?time_range=long_term&limit=10`;
type TrackSchema = {
name: string;
artists: Array<{
name: string;
}>;
album: {
name: string;
images: Array<{
url: string;
}>;
};
imageUrl?: string;
external_urls: {
spotify: string;
};
};
type Track = {
isPlaying: boolean;
artist?: string;
title?: string;
album?: string;
imageUrl?: string;
songUrl?: string;
};
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async (req: VercelRequest, res: VercelResponse) => {
try {
@@ -106,11 +81,6 @@ const getNowPlaying = async (): Promise<Track> => {
},
});
type Activity = {
is_playing: boolean;
item?: TrackSchema;
};
if (response.status === 204 || response.status > 400) {
return { isPlaying: false };
}