mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-07-11 10:37:16 +03:00
feat: update diagnostics checks
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
import { IBaseApiResponse } from '../types';
|
||||
|
||||
export async function createBaseApiRequest<T>(
|
||||
fetchFn: () => Promise<Response>,
|
||||
): Promise<IBaseApiResponse<T>> {
|
||||
try {
|
||||
const response = await fetchFn();
|
||||
|
||||
if (!response.ok) {
|
||||
return {
|
||||
success: false as const,
|
||||
message: `${_('HTTP error')} ${response.status}: ${response.statusText}`,
|
||||
};
|
||||
}
|
||||
|
||||
const data: T = await response.json();
|
||||
|
||||
return {
|
||||
success: true as const,
|
||||
data,
|
||||
};
|
||||
} catch (e) {
|
||||
return {
|
||||
success: false as const,
|
||||
message: e instanceof Error ? e.message : _('Unknown error'),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ClashAPI, IBaseApiResponse } from '../types';
|
||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
||||
import { ClashAPI } from '../types';
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function getClashConfig(): Promise<
|
||||
IBaseApiResponse<ClashAPI.Config>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ClashAPI, IBaseApiResponse } from '../types';
|
||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
||||
import { ClashAPI } from '../types';
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function getClashGroupDelay(
|
||||
group: string,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ClashAPI, IBaseApiResponse } from '../types';
|
||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
||||
import { ClashAPI } from '../types';
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function getClashProxies(): Promise<
|
||||
IBaseApiResponse<ClashAPI.Proxies>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ClashAPI, IBaseApiResponse } from '../types';
|
||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
||||
import { ClashAPI } from '../types';
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function getClashVersion(): Promise<
|
||||
IBaseApiResponse<ClashAPI.Version>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from './createBaseApiRequest';
|
||||
export * from './getConfig';
|
||||
export * from './getGroupDelay';
|
||||
export * from './getProxies';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IBaseApiResponse } from '../types';
|
||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function triggerLatencyGroupTest(
|
||||
tag: string,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IBaseApiResponse } from '../types';
|
||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function triggerProxySelector(
|
||||
selector: string,
|
||||
|
||||
Reference in New Issue
Block a user