他のエンドポイントを呼ぶ関数にも適用
This commit is contained in:
@@ -56,7 +56,12 @@ export function api<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoin
|
|||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function apiExternal<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req']>(hostUrl: string, endpoint: E, data: P = {} as any, token?: string | null | undefined, signal?: AbortSignal): Promise<Misskey.Endpoints[E]['res']> {
|
export function apiExternal<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req']>(
|
||||||
|
hostUrl: string,
|
||||||
|
endpoint: E, data: P = {} as any,
|
||||||
|
token?: string | null | undefined,
|
||||||
|
signal?: AbortSignal,
|
||||||
|
): Promise<Misskey.api.SwitchCaseResponseType<E, P>> {
|
||||||
if (!/^https?:\/\//.test(hostUrl)) throw new Error('invalid host name');
|
if (!/^https?:\/\//.test(hostUrl)) throw new Error('invalid host name');
|
||||||
if (endpoint.includes('://')) throw new Error('invalid endpoint');
|
if (endpoint.includes('://')) throw new Error('invalid endpoint');
|
||||||
pendingApiRequestsCount.value++;
|
pendingApiRequestsCount.value++;
|
||||||
@@ -100,7 +105,10 @@ export function apiExternal<E extends keyof Misskey.Endpoints, P extends Misskey
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implements Misskey.api.ApiClient.request
|
// Implements Misskey.api.ApiClient.request
|
||||||
export function apiGet <E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req']>(endpoint: E, data: P = {} as any): Promise<Misskey.Endpoints[E]['res']> {
|
export function apiGet<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req']>(
|
||||||
|
endpoint: E,
|
||||||
|
data: P = {} as any,
|
||||||
|
): Promise<Misskey.api.SwitchCaseResponseType<E, P>> {
|
||||||
pendingApiRequestsCount.value++;
|
pendingApiRequestsCount.value++;
|
||||||
|
|
||||||
const onFinally = () => {
|
const onFinally = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user