mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
refactor(web): use ImmichApi to create urls (#2435)
This commit is contained in:
parent
15fa8250cb
commit
4524aa0d06
13 changed files with 53 additions and 51 deletions
|
|
@ -2,6 +2,7 @@ import {
|
|||
AlbumApi,
|
||||
APIKeyApi,
|
||||
AssetApi,
|
||||
AssetApiFp,
|
||||
AuthenticationApi,
|
||||
Configuration,
|
||||
ConfigurationParameters,
|
||||
|
|
@ -11,11 +12,12 @@ import {
|
|||
ServerInfoApi,
|
||||
ShareApi,
|
||||
SystemConfigApi,
|
||||
ThumbnailFormat,
|
||||
UserApi
|
||||
UserApi,
|
||||
UserApiFp
|
||||
} from './open-api';
|
||||
import { BASE_PATH } from './open-api/base';
|
||||
import { DUMMY_BASE_URL, toPathString } from './open-api/common';
|
||||
import type { ApiParams } from './types';
|
||||
|
||||
export class ImmichApi {
|
||||
public userApi: UserApi;
|
||||
|
|
@ -75,15 +77,24 @@ export class ImmichApi {
|
|||
this.config.basePath = baseUrl;
|
||||
}
|
||||
|
||||
public getAssetFileUrl(assetId: string, isThumb?: boolean, isWeb?: boolean, key?: string) {
|
||||
public getAssetFileUrl(
|
||||
...[assetId, isThumb, isWeb, key]: ApiParams<typeof AssetApiFp, 'serveFile'>
|
||||
) {
|
||||
const path = `/asset/file/${assetId}`;
|
||||
return this.createUrl(path, { isThumb, isWeb, key });
|
||||
}
|
||||
|
||||
public getAssetThumbnailUrl(assetId: string, format?: ThumbnailFormat, key?: string) {
|
||||
public getAssetThumbnailUrl(
|
||||
...[assetId, format, key]: ApiParams<typeof AssetApiFp, 'getAssetThumbnail'>
|
||||
) {
|
||||
const path = `/asset/thumbnail/${assetId}`;
|
||||
return this.createUrl(path, { format, key });
|
||||
}
|
||||
|
||||
public getProfileImageUrl(...[userId]: ApiParams<typeof UserApiFp, 'getProfileImage'>) {
|
||||
const path = `/user/profile-image/${userId}`;
|
||||
return this.createUrl(path);
|
||||
}
|
||||
}
|
||||
|
||||
export const api = new ImmichApi({ basePath: '/api' });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue