Skip to content

Commit

Permalink
fix(types): use typescript strict
Browse files Browse the repository at this point in the history
  • Loading branch information
cubedhuang committed Apr 18, 2022
1 parent dd701f1 commit a95676f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/pages/api/topMusic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type TopMusicResponseSuccess = {
medium: SpotifyApi.UsersTopTracksResponse;
long: SpotifyApi.UsersTopTracksResponse;
};
export type TopMusicResponseError = { error: string };
export type TopMusicResponseError = { error: unknown };
export type TopMusicResponse = TopMusicResponseSuccess | TopMusicResponseError;

const api = new Spotify({
Expand All @@ -28,7 +28,7 @@ export default async function handler(
}

try {
if (Date.now() > cachedTime) {
if (!cached || Date.now() > cachedTime) {
if (Date.now() > expirationTime) {
const response = await api.refreshAccessToken();
api.setAccessToken(response.body.access_token);
Expand Down Expand Up @@ -60,6 +60,6 @@ export default async function handler(

res.status(200).json(cached);
} catch (err) {
res.status(500).json({ error: err?.message });
res.status(500).json({ error: (err as any)?.message });
}
}
4 changes: 2 additions & 2 deletions src/pages/api/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from "next";
import Spotify from "spotify-web-api-node";

export type TrackResponseSuccess = SpotifyApi.SingleTrackResponse;
export type TrackResponseError = { error: string };
export type TrackResponseError = { error: unknown };
export type TrackResponse = TrackResponseSuccess | TrackResponseError;

const api = new Spotify({
Expand Down Expand Up @@ -45,6 +45,6 @@ export default async function handler(
const response = await api.getTrack(id);
res.status(200).json(response.body);
} catch (err) {
res.status(500).json({ error: err?.message });
res.status(500).json({ error: (err as any)?.message });
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
Expand Down

0 comments on commit a95676f

Please sign in to comment.