Skip to content

Commit 735c13a

Browse files
committed
feat(bundle): move endpoint import to actual clients instead of base
1 parent e246d52 commit 735c13a

File tree

6 files changed

+39
-10
lines changed

6 files changed

+39
-10
lines changed

src/services/tmdb-client/clients/base-tmdb-client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import type {
1111
TmdbClientSettings,
1212
TmdbPaginatedData,
1313
} from '~/models/tmdb/tmdb-client.model';
14+
import type { tmdbApi } from '~/services/tmdb-client/api/tmdb-api.endpoint';
1415

1516
import { TraktApiHeaders } from '~/models/trakt/trakt-client.model';
1617
import { BaseApiHeaders, type BaseBody, BaseClient, BaseHeaderContentType, parseBody, parseUrl } from '~/services/common/base-client';
17-
import { tmdbApi } from '~/services/tmdb-client/api/tmdb-api.endpoint';
1818

1919
/**
2020
* The extracted type signature of the TmdbApi
@@ -65,7 +65,7 @@ export class BaseTmdbClient
6565
* @param authentication - The authentication for the client.
6666
* @param api - The API endpoints for the client.
6767
*/
68-
constructor(options: TmdbClientOptions, authentication: TmdbClientAuthentication = {}, api: ITmdbApi = tmdbApi) {
68+
constructor(options: TmdbClientOptions, authentication: TmdbClientAuthentication = {}, api: ITmdbApi = {}) {
6969
super(options, authentication, api);
7070
}
7171

src/services/tmdb-client/clients/tmdb-client.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import type { TmdbClientAuthentication } from '~/models/tmdb/tmdb-client.model';
1+
import type { TmdbClientAuthentication, TmdbClientSettings } from '~/models/tmdb/tmdb-client.model';
22

3+
import { tmdbApi } from '~/services/tmdb-client/api/tmdb-api.endpoint';
34
import { BaseTmdbClient } from '~/services/tmdb-client/clients/base-tmdb-client';
45
import { Config } from '~/settings/tmdb.api';
56

@@ -11,6 +12,15 @@ import { Config } from '~/settings/tmdb.api';
1112
* @extends {BaseTmdbClient}
1213
*/
1314
export class TmdbClient extends BaseTmdbClient {
15+
/**
16+
* Creates an instance of TmdbClient, with the necessary endpoints and settings.
17+
* @param settings - The settings for the client.
18+
* @param authentication - The authentication for the client.
19+
*/
20+
constructor(settings: TmdbClientSettings, authentication: TmdbClientAuthentication = {}) {
21+
super(settings, authentication, tmdbApi);
22+
}
23+
1424
/**
1525
* This is step #1 from the [user authentication]{@link https://developer.themoviedb.org/v4/docs/authentication-user} page.
1626
*

src/services/trakt-client/clients/base-trakt-client.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import type {
99
TraktClientSettings,
1010
} from '~/models/trakt/trakt-client.model';
1111

12+
import type { traktApi } from '~/services/trakt-client/api/trakt-api.endpoints';
1213
import type { Primitive } from '~/utils/typescript.utils';
1314

1415
import { TraktApiHeaders } from '~/models/trakt/trakt-client.model';
15-
1616
import { type BaseBody, BaseClient, BaseHeaderContentType, parseBody, parseUrl } from '~/services/common/base-client';
17-
import { traktApi } from '~/services/trakt-client/api/trakt-api.endpoints';
1817
import { isFilter, TraktApiFilterValidator } from '~/services/trakt-client/api/trakt-api.filters';
1918

2019
/**
@@ -125,7 +124,7 @@ export class BaseTraktClient
125124
* @param authentication - The authentication for the client.
126125
* @param api - The API endpoints for the client.
127126
*/
128-
constructor(options: TraktClientOptions, authentication: TraktClientAuthentication = {}, api: ITraktApi = traktApi) {
127+
constructor(options: TraktClientOptions, authentication: TraktClientAuthentication = {}, api: ITraktApi = {}) {
129128
super(options, authentication, api);
130129
}
131130

src/services/trakt-client/clients/trakt-client.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import type {
1010
TraktClientAuthentication,
1111
TraktDeviceAuthentication,
1212
} from '~/models/trakt/trakt-authentication.model';
13-
import type { TraktApiInit, TraktApiResponse } from '~/models/trakt/trakt-client.model';
13+
import type { TraktApiInit, TraktApiResponse, TraktClientSettings } from '~/models/trakt/trakt-client.model';
1414

1515
import { TraktApiHeaders } from '~/models/trakt/trakt-client.model';
16+
import { traktApi } from '~/services/trakt-client/api/trakt-api.endpoints';
1617
import { randomHex } from '~/utils/crypto.utils';
1718

1819
/**
@@ -49,6 +50,15 @@ const handleError = <T>(error: T | Response) => {
4950
export class TraktClient extends BaseTraktClient {
5051
private polling: ReturnType<typeof setTimeout> | undefined;
5152

53+
/**
54+
* Creates an instance of TraktClient, with the necessary endpoints and settings.
55+
* @param settings - The settings for the client.
56+
* @param authentication - The authentication for the client.
57+
*/
58+
constructor(settings: TraktClientSettings, authentication: TraktClientAuthentication = {}) {
59+
super(settings, authentication, traktApi);
60+
}
61+
5262
/**
5363
* Exchanges an authorization code or refresh token for an access token.
5464
*

src/services/tvdb-client/clients/base-tvdb-client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import type {
99
TvdbClientOptions,
1010
TvdbClientSettings,
1111
} from '~/models/tvdb/tvdb-client.model';
12+
import type { tvdbApi } from '~/services/tvdb-client/api/tvdb-api.endpoint';
1213

1314
import { TraktApiHeaders } from '~/models/trakt/trakt-client.model';
1415
import { BaseApiHeaders, type BaseBody, BaseClient, BaseHeaderContentType, parseBody, parseUrl } from '~/services/common/base-client';
15-
import { tvdbApi } from '~/services/tvdb-client/api/tvdb-api.endpoint';
1616

1717
/**
1818
* The extracted type signature of the TvdbApi
@@ -39,7 +39,7 @@ export class BaseTvdbClient
3939
* @param authentication - The authentication for the client.
4040
* @param api - The API endpoints for the client.
4141
*/
42-
constructor(options: TvdbClientOptions, authentication: TvdbClientAuthentication = {}, api: ITvdbApi = tvdbApi) {
42+
constructor(options: TvdbClientOptions, authentication: TvdbClientAuthentication = {}, api: ITvdbApi = {}) {
4343
super(options, authentication, api);
4444
}
4545

src/services/tvdb-client/clients/tvdb-client.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import type { TvdbClientAuthentication } from '~/models/tvdb/tvdb-client.model';
1+
import type { TvdbClientAuthentication, TvdbClientSettings } from '~/models/tvdb/tvdb-client.model';
22

3+
import { tvdbApi } from '~/services/tvdb-client/api/tvdb-api.endpoint';
34
import { BaseTvdbClient } from '~/services/tvdb-client/clients/base-tvdb-client';
45

56
/**
@@ -10,6 +11,15 @@ import { BaseTvdbClient } from '~/services/tvdb-client/clients/base-tvdb-client'
1011
* @extends {BaseTvdbClient}
1112
*/
1213
export class TvdbClient extends BaseTvdbClient {
14+
/**
15+
* Creates an instance of TvdbClient, with the necessary endpoints and settings.
16+
* @param settings - The settings for the client.
17+
* @param authentication - The authentication for the client.
18+
*/
19+
constructor(settings: TvdbClientSettings, authentication: TvdbClientAuthentication = {}) {
20+
super(settings, authentication, tvdbApi);
21+
}
22+
1323
/**
1424
* Authenticates the client with the setting's secret and an optionally provided user pin.
1525
* The access token is stored in the client and used for all subsequent requests.

0 commit comments

Comments
 (0)