api augmentations & added streamyfin plugin id

This commit is contained in:
herrrta
2025-01-09 08:51:53 -05:00
parent e1720a00da
commit 54af64abef
2 changed files with 38 additions and 8 deletions

30
augmentations/api.ts Normal file
View File

@@ -0,0 +1,30 @@
import {Api, AUTHORIZATION_HEADER} from "@jellyfin/sdk";
import {AxiosRequestConfig, AxiosResponse} from "axios";
import {StreamyfinPluginConfig} from "@/utils/atoms/settings";
declare module '@jellyfin/sdk' {
interface Api {
get<T, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T>>
post<T, D = any>(url: string, data: D, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T>>
getStreamyfinPluginConfig(): Promise<AxiosResponse<StreamyfinPluginConfig>>
}
}
Api.prototype.get = function <T, D = any> (url: string, config: AxiosRequestConfig<D> = {}): Promise<AxiosResponse<T>> {
return this.axiosInstance.get<T>(`${this.basePath}${url}`, {
...(config ?? {}),
headers: { [AUTHORIZATION_HEADER]: this.authorizationHeader }
})
}
Api.prototype.post = function <T, D = any> (url: string, data: D, config: AxiosRequestConfig<D>): Promise<AxiosResponse<T>> {
return this.axiosInstance.post<T>(`${this.basePath}${url}`, {
...(config || {}),
data,
headers: { [AUTHORIZATION_HEADER]: this.authorizationHeader }}
)
}
Api.prototype.getStreamyfinPluginConfig = function (): Promise<AxiosResponse<StreamyfinPluginConfig>> {
return this.get<StreamyfinPluginConfig>("/Streamyfin/config")
}