Skip to content

Commit

Permalink
fixup! fix(managers): do not create http client per each manager
Browse files Browse the repository at this point in the history
  • Loading branch information
seth2810 committed Jul 29, 2024
1 parent c4759a6 commit d660ce8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/lib/SpotifyAPI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SpotifyConfig } from '../interfaces/Config';
import { PrivateConfig, SpotifyConfig } from '../interfaces/Config';
import { AlbumManager } from './album/AlbumManager';
import { ArtistManager } from './artist/ArtistManager';
import { AudioManager } from './audio/AudioManager';
Expand Down Expand Up @@ -29,16 +29,17 @@ export class SpotifyAPI {

playlist: PlaylistManager;

constructor(config: SpotifyConfig) {
// eslint-disable-next-line deprecation/deprecation
const { acccessToken, ...httpClientConfig } = config;
private privateConfig: PrivateConfig = {};

constructor(public config: SpotifyConfig) {
// TODO: remove for v2
if (!httpClientConfig.accessToken && acccessToken) {
httpClientConfig.accessToken = acccessToken;
// eslint-disable-next-line deprecation/deprecation
if (!this.config.accessToken && config.acccessToken) {
// eslint-disable-next-line deprecation/deprecation
this.config.accessToken = config.acccessToken;
}

const client = new HttpClient(httpClientConfig, {});
const client = new HttpClient(this.config, this.privateConfig);

this.tracks = new TrackManager(client);
this.albums = new AlbumManager(client);
Expand Down

0 comments on commit d660ce8

Please sign in to comment.