diff --git a/apps/api/src/xrpc/app/rocksky/spotify/getCurrentlyPlaying.ts b/apps/api/src/xrpc/app/rocksky/spotify/getCurrentlyPlaying.ts index ec918e69..5d31ead8 100644 --- a/apps/api/src/xrpc/app/rocksky/spotify/getCurrentlyPlaying.ts +++ b/apps/api/src/xrpc/app/rocksky/spotify/getCurrentlyPlaying.ts @@ -23,7 +23,7 @@ export default function (server: Server, ctx: Context) { Effect.catchAll((err) => { console.error(err); return Effect.succeed({}); - }), + }) ); server.app.rocksky.spotify.getCurrentlyPlaying({ auth: ctx.authVerifier, @@ -54,8 +54,8 @@ const withUser = ({ .where( or( eq(tables.users.did, params.actor || did), - eq(tables.users.handle, params.actor || did), - ), + eq(tables.users.handle, params.actor || did) + ) ) .execute() .then((users) => ({ user: users[0], ctx, params, did })), @@ -90,13 +90,13 @@ const withSpotifyAccount = ({ .from(tables.spotifyAccounts) .leftJoin( tables.users, - eq(tables.users.id, tables.spotifyAccounts.userId), + eq(tables.users.id, tables.spotifyAccounts.userId) ) .where( or( eq(tables.users.did, params.actor || did), - eq(tables.users.handle, params.actor || did), - ), + eq(tables.users.handle, params.actor || did) + ) ) .execute() .then(([results]) => ({ @@ -129,8 +129,8 @@ const retrieve = ({ Match.value(cached).pipe( Match.when(null, () => ({})), Match.when(undefined, () => ({})), - Match.orElse(() => JSON.parse(cached)), - ), + Match.orElse(() => JSON.parse(cached)) + ) ) .then((cached) => [cached, ctx, user]), catch: (error) => @@ -143,7 +143,7 @@ const withUriAndLikes = ([track, ctx, user]: [any, Context, SelectUser]) => { try: async () => { const sha256 = createHash("sha256") .update( - `${track.item.name} - ${track.item.artists.map((x) => x.name).join(", ")} - ${track.item.album.name}`.toLowerCase(), + `${track.item.name} - ${track.item.artists.map((x) => x.name).join(", ")} - ${track.item.album.name}`.toLowerCase() ) .digest("hex"); const [record] = await ctx.db @@ -156,18 +156,18 @@ const withUriAndLikes = ([track, ctx, user]: [any, Context, SelectUser]) => { .from(tables.lovedTracks) .leftJoin( tables.tracks, - eq(tables.lovedTracks.trackId, tables.tracks.id), + eq(tables.lovedTracks.trackId, tables.tracks.id) ) .leftJoin(tables.users, eq(tables.lovedTracks.userId, tables.users.id)) .where( - and(eq(tables.tracks.sha256, sha256), eq(tables.users.did, user.did)), + and(eq(tables.tracks.sha256, sha256), eq(tables.users.did, user.did)) ) .execute() .then((results) => Match.value(track).pipe( Match.when( (t) => !Object.keys(t).length, - () => ({}), + () => ({}) ), Match.orElse(() => ({ ...track, @@ -175,8 +175,8 @@ const withUriAndLikes = ([track, ctx, user]: [any, Context, SelectUser]) => { artistUri: record?.artistUri, albumUri: record?.albumUri, liked: results.length > 0, - })), - ), + })) + ) ); }, catch: (error) => new Error(`Failed to retrieve URI and likes: ${error}`), diff --git a/apps/api/src/xrpc/app/rocksky/spotify/next.ts b/apps/api/src/xrpc/app/rocksky/spotify/next.ts index 807be015..6aece723 100644 --- a/apps/api/src/xrpc/app/rocksky/spotify/next.ts +++ b/apps/api/src/xrpc/app/rocksky/spotify/next.ts @@ -23,7 +23,7 @@ export default function (server: Server, ctx: Context) { Effect.catchAll((err) => { console.error(err); return Effect.succeed({}); - }), + }) ); server.app.rocksky.spotify.next({ auth: ctx.authVerifier, @@ -72,7 +72,7 @@ const withSpotifyRefreshToken = ({ .where(eq(tables.spotifyTokens.userId, user.id)) .execute() .then(([spotifyToken]) => - decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY), + decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY) ) .then((refreshToken) => ({ user, @@ -105,7 +105,7 @@ const withSpotifyToken = ({ client_secret: env.SPOTIFY_CLIENT_SECRET, }), }) - .then((res) => res.json()) + .then((res) => res.json() as Promise<{ access_token: string }>) .then((data) => data.access_token), catch: (error) => new Error(`Failed to retrieve Spotify token: ${error}`), }); diff --git a/apps/api/src/xrpc/app/rocksky/spotify/pause.ts b/apps/api/src/xrpc/app/rocksky/spotify/pause.ts index 42d01111..4ce6568c 100644 --- a/apps/api/src/xrpc/app/rocksky/spotify/pause.ts +++ b/apps/api/src/xrpc/app/rocksky/spotify/pause.ts @@ -23,7 +23,7 @@ export default function (server: Server, ctx: Context) { Effect.catchAll((err) => { console.error(err); return Effect.succeed({}); - }), + }) ); server.app.rocksky.spotify.pause({ auth: ctx.authVerifier, @@ -72,7 +72,7 @@ const withSpotifyRefreshToken = ({ .where(eq(tables.spotifyTokens.userId, user.id)) .execute() .then(([spotifyToken]) => - decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY), + decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY) ) .then((refreshToken) => ({ user, @@ -86,7 +86,6 @@ const withSpotifyRefreshToken = ({ const withSpotifyToken = ({ refreshToken, - ctx, }: { refreshToken: string; ctx: Context; @@ -105,7 +104,7 @@ const withSpotifyToken = ({ client_secret: env.SPOTIFY_CLIENT_SECRET, }), }) - .then((res) => res.json()) + .then((res) => res.json() as Promise<{ access_token: string }>) .then((data) => data.access_token), catch: (error) => new Error(`Failed to retrieve Spotify token: ${error}`), }); diff --git a/apps/api/src/xrpc/app/rocksky/spotify/play.ts b/apps/api/src/xrpc/app/rocksky/spotify/play.ts index 6421e4ca..152ff160 100644 --- a/apps/api/src/xrpc/app/rocksky/spotify/play.ts +++ b/apps/api/src/xrpc/app/rocksky/spotify/play.ts @@ -23,7 +23,7 @@ export default function (server: Server, ctx: Context) { Effect.catchAll((err) => { console.error(err); return Effect.succeed({}); - }), + }) ); server.app.rocksky.spotify.play({ auth: ctx.authVerifier, @@ -72,7 +72,7 @@ const withSpotifyRefreshToken = ({ .where(eq(tables.spotifyTokens.userId, user.id)) .execute() .then(([spotifyToken]) => - decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY), + decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY) ) .then((refreshToken) => ({ user, @@ -105,7 +105,7 @@ const withSpotifyToken = ({ client_secret: env.SPOTIFY_CLIENT_SECRET, }), }) - .then((res) => res.json()) + .then((res) => res.json() as Promise<{ access_token: string }>) .then((data) => data.access_token), catch: (error) => new Error(`Failed to retrieve Spotify token: ${error}`), }); diff --git a/apps/api/src/xrpc/app/rocksky/spotify/previous.ts b/apps/api/src/xrpc/app/rocksky/spotify/previous.ts index 9c9df550..9876e8fe 100644 --- a/apps/api/src/xrpc/app/rocksky/spotify/previous.ts +++ b/apps/api/src/xrpc/app/rocksky/spotify/previous.ts @@ -23,7 +23,7 @@ export default function (server: Server, ctx: Context) { Effect.catchAll((err) => { console.error(err); return Effect.succeed({}); - }), + }) ); server.app.rocksky.spotify.previous({ auth: ctx.authVerifier, @@ -72,7 +72,7 @@ const withSpotifyRefreshToken = ({ .where(eq(tables.spotifyTokens.userId, user.id)) .execute() .then(([spotifyToken]) => - decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY), + decrypt(spotifyToken.refreshToken, env.SPOTIFY_ENCRYPTION_KEY) ) .then((refreshToken) => ({ refreshToken, @@ -97,7 +97,7 @@ const withSpotifyToken = ({ refreshToken }: { refreshToken: string }) => { client_secret: env.SPOTIFY_CLIENT_SECRET, }), }) - .then((res) => res.json()) + .then((res) => res.json() as Promise<{ access_token: string }>) .then((data) => data.access_token), catch: (error) => new Error(`Failed to retrieve Spotify token: ${error}`), }); diff --git a/apps/api/src/xrpc/app/rocksky/spotify/seek.ts b/apps/api/src/xrpc/app/rocksky/spotify/seek.ts index a41b9cc8..5c12f259 100644 --- a/apps/api/src/xrpc/app/rocksky/spotify/seek.ts +++ b/apps/api/src/xrpc/app/rocksky/spotify/seek.ts @@ -107,7 +107,7 @@ const withSpotifyToken = ({ client_secret: env.SPOTIFY_CLIENT_SECRET, }), }) - .then((res) => res.json()) + .then((res) => res.json() as Promise<{ access_token: string }>) .then((data) => ({ accessToken: data.access_token, position: params.position,