UNPKG

@snail-js/api

Version:

Http Request with Decorators Api, build on axios

32 lines (31 loc) 1.52 kB
import { AxiosRequestConfig, AxiosResponse } from "axios"; import { Strategy } from "../typings"; export declare function generateCacheKey(methodName: string, version: string | undefined, request: AxiosRequestConfig): Promise<string>; export declare function generateShortUniqueHash(str: string): Promise<string>; export declare function recordToString(record: Record<string, any>): string; export declare function replacePlaceholders(route: string, values: { [key: string]: any; }): string; export declare const resolveUrl: (url?: string) => string; export declare function applyStrategies<T extends "request">(data: AxiosRequestConfig, strategies: Array<new () => Strategy>, type: T): Promise<AxiosRequestConfig>; export declare function applyStrategies<T extends "response">(data: AxiosResponse, strategies: Array<new () => Strategy>, type: T): Promise<AxiosResponse>; /** * 一个无用函数,避免tsc报错 */ export declare const SnailPass: (...args: any) => void; interface IJson { [key: string]: any; } interface IArgs { params: IJson; data: IJson; querys: IJson; } export declare const buildRequestArgs: (target: any, propertyKey: string, args: any[]) => IArgs; /** * 判断响应的数据类型是否为 application/json * @param {AxiosResponse} response - Axios 的响应对象 * @returns {boolean} - 如果响应的数据类型是 application/json 则返回 true,否则返回 false */ export declare function isSpecialResponse(response: AxiosResponse): boolean; export {};