mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
chore(api): update dependencies
This commit is contained in:
parent
05f230a7ce
commit
d881a78757
37 changed files with 4804 additions and 2700 deletions
|
|
@ -2,6 +2,6 @@ import { Module } from "@nestjs/common";
|
|||
import { SpotifyModule } from "./spotify/spotify.module";
|
||||
|
||||
@Module({
|
||||
imports: [SpotifyModule]
|
||||
imports: [SpotifyModule],
|
||||
})
|
||||
export class SourcesModule {}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import { SpotifyApiService } from "./spotify-api.service";
|
|||
HttpModule.registerAsync({
|
||||
useFactory: () => ({
|
||||
timeout: 5000,
|
||||
baseURL: "https://api.spotify.com/"
|
||||
})
|
||||
})
|
||||
baseURL: "https://api.spotify.com/",
|
||||
}),
|
||||
}),
|
||||
],
|
||||
providers: [SpotifyApiService],
|
||||
exports: [SpotifyApiService]
|
||||
exports: [SpotifyApiService],
|
||||
})
|
||||
export class SpotifyApiModule {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { SpotifyApiService } from './spotify-api.service';
|
||||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { SpotifyApiService } from "./spotify-api.service";
|
||||
|
||||
describe('SpotifyApiService', () => {
|
||||
describe("SpotifyApiService", () => {
|
||||
let service: SpotifyApiService;
|
||||
|
||||
beforeEach(async () => {
|
||||
|
|
@ -12,7 +12,7 @@ describe('SpotifyApiService', () => {
|
|||
service = module.get<SpotifyApiService>(SpotifyApiService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
it("should be defined", () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ export class SpotifyApiService {
|
|||
|
||||
async getRecentlyPlayedTracks({
|
||||
accessToken,
|
||||
lastRefreshTime
|
||||
lastRefreshTime,
|
||||
}: SpotifyConnection): Promise<PlayHistoryObject[]> {
|
||||
console.log("SpotifyApiService#getRecentlyPlayedTracks");
|
||||
|
||||
const parameters: { limit: number; after?: number } = {
|
||||
limit: 50
|
||||
limit: 50,
|
||||
};
|
||||
|
||||
if (lastRefreshTime) {
|
||||
|
|
@ -33,7 +33,7 @@ export class SpotifyApiService {
|
|||
const history = await this.httpService
|
||||
.get<PagingObject<PlayHistoryObject>>(`v1/me/player/recently-played`, {
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
params: parameters
|
||||
params: parameters,
|
||||
})
|
||||
.toPromise();
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ export class SpotifyApiService {
|
|||
console.log("SpotifyApiService#getArtist");
|
||||
const artist = await this.httpService
|
||||
.get<ArtistObject>(`v1/artists/${spotifyID}`, {
|
||||
headers: { Authorization: `Bearer ${accessToken}` }
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
})
|
||||
.toPromise();
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ export class SpotifyApiService {
|
|||
|
||||
const album = await this.httpService
|
||||
.get<AlbumObject>(`v1/albums/${spotifyID}`, {
|
||||
headers: { Authorization: `Bearer ${accessToken}` }
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
})
|
||||
.toPromise();
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ export class SpotifyApiService {
|
|||
|
||||
const track = await this.httpService
|
||||
.get<TrackObject>(`v1/tracks/${spotifyID}`, {
|
||||
headers: { Authorization: `Bearer ${accessToken}` }
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
})
|
||||
.toPromise();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import { SpotifyAuthService } from "./spotify-auth.service";
|
|||
HttpModule.registerAsync({
|
||||
useFactory: () => ({
|
||||
timeout: 5000,
|
||||
baseURL: "https://accounts.spotify.com/"
|
||||
})
|
||||
})
|
||||
baseURL: "https://accounts.spotify.com/",
|
||||
}),
|
||||
}),
|
||||
],
|
||||
providers: [SpotifyAuthService],
|
||||
exports: [SpotifyAuthService]
|
||||
exports: [SpotifyAuthService],
|
||||
})
|
||||
export class SpotifyAuthModule {}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ export class SpotifyAuthService {
|
|||
{
|
||||
auth: {
|
||||
username: this.clientID,
|
||||
password: this.clientSecret
|
||||
}
|
||||
password: this.clientSecret,
|
||||
},
|
||||
}
|
||||
)
|
||||
.toPromise();
|
||||
|
|
@ -40,8 +40,8 @@ export class SpotifyAuthService {
|
|||
{
|
||||
auth: {
|
||||
username: this.clientID,
|
||||
password: this.clientSecret
|
||||
}
|
||||
password: this.clientSecret,
|
||||
},
|
||||
}
|
||||
)
|
||||
.toPromise();
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import { SpotifyAuthModule } from "./spotify-auth/spotify-auth.module";
|
|||
ListensModule,
|
||||
MusicLibraryModule,
|
||||
SpotifyApiModule,
|
||||
SpotifyAuthModule
|
||||
SpotifyAuthModule,
|
||||
],
|
||||
providers: [SpotifyService]
|
||||
providers: [SpotifyService],
|
||||
})
|
||||
export class SpotifyModule {}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe("SpotifyService", () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [SpotifyService]
|
||||
providers: [SpotifyService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<SpotifyService>(SpotifyService);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export class SpotifyService {
|
|||
);
|
||||
await this.usersService.updateSpotifyConnection(user, {
|
||||
...user.spotify,
|
||||
accessToken
|
||||
accessToken,
|
||||
});
|
||||
await this.processUser(user, false);
|
||||
}
|
||||
|
|
@ -62,13 +62,13 @@ export class SpotifyService {
|
|||
}
|
||||
|
||||
await Promise.all(
|
||||
playHistory.map(async history => {
|
||||
playHistory.map(async (history) => {
|
||||
const track = await this.importTrack(history.track.id);
|
||||
|
||||
this.listensService.createListen({
|
||||
user,
|
||||
track,
|
||||
playedAt: new Date(history.played_at)
|
||||
playedAt: new Date(history.played_at),
|
||||
});
|
||||
|
||||
console.log(
|
||||
|
|
@ -79,19 +79,19 @@ export class SpotifyService {
|
|||
|
||||
const newestPlayTime = new Date(
|
||||
playHistory
|
||||
.map(history => history.played_at)
|
||||
.map((history) => history.played_at)
|
||||
.sort()
|
||||
.pop()
|
||||
);
|
||||
|
||||
console.log("newestPlayTime", {
|
||||
newestPlayTime,
|
||||
times: playHistory.map(history => history.played_at).sort()
|
||||
times: playHistory.map((history) => history.played_at).sort(),
|
||||
});
|
||||
|
||||
this.usersService.updateSpotifyConnection(user, {
|
||||
...user.spotify,
|
||||
lastRefreshTime: newestPlayTime
|
||||
lastRefreshTime: newestPlayTime,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ export class SpotifyService {
|
|||
retryOnExpiredToken: boolean = true
|
||||
): Promise<Track> {
|
||||
const track = await this.musicLibraryService.findTrack({
|
||||
spotify: { id: spotifyID }
|
||||
spotify: { id: spotifyID },
|
||||
});
|
||||
if (track) {
|
||||
return track;
|
||||
|
|
@ -129,7 +129,7 @@ export class SpotifyService {
|
|||
spotifyTrack.artists.map(({ id: artistID }) =>
|
||||
this.importArtist(artistID)
|
||||
)
|
||||
)
|
||||
),
|
||||
]);
|
||||
|
||||
return this.musicLibraryService.createTrack({
|
||||
|
|
@ -140,8 +140,8 @@ export class SpotifyService {
|
|||
id: spotifyTrack.id,
|
||||
uri: spotifyTrack.uri,
|
||||
type: spotifyTrack.type,
|
||||
href: spotifyTrack.href
|
||||
}
|
||||
href: spotifyTrack.href,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ export class SpotifyService {
|
|||
retryOnExpiredToken: boolean = true
|
||||
): Promise<Album> {
|
||||
const album = await this.musicLibraryService.findAlbum({
|
||||
spotify: { id: spotifyID }
|
||||
spotify: { id: spotifyID },
|
||||
});
|
||||
if (album) {
|
||||
return album;
|
||||
|
|
@ -186,8 +186,8 @@ export class SpotifyService {
|
|||
id: spotifyAlbum.id,
|
||||
uri: spotifyAlbum.uri,
|
||||
type: spotifyAlbum.type,
|
||||
href: spotifyAlbum.href
|
||||
}
|
||||
href: spotifyAlbum.href,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ export class SpotifyService {
|
|||
retryOnExpiredToken: boolean = true
|
||||
): Promise<Artist> {
|
||||
const artist = await this.musicLibraryService.findArtist({
|
||||
spotify: { id: spotifyID }
|
||||
spotify: { id: spotifyID },
|
||||
});
|
||||
if (artist) {
|
||||
return artist;
|
||||
|
|
@ -225,8 +225,8 @@ export class SpotifyService {
|
|||
id: spotifyArtist.id,
|
||||
uri: spotifyArtist.uri,
|
||||
type: spotifyArtist.type,
|
||||
href: spotifyArtist.href
|
||||
}
|
||||
href: spotifyArtist.href,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue