lingva-scraper-update
Version:
Google Translate scraper for Lingva Translate
32 lines (31 loc) • 933 B
TypeScript
import { AxiosResponse } from "axios";
import { LangCodeGoogle } from "./language";
export declare const Endpoint: {
readonly INFO: "info";
readonly TEXT: "text";
readonly AUDIO: "audio";
};
declare type EndpointType = (typeof Endpoint)[keyof typeof Endpoint];
declare type Params = {
[Endpoint.INFO]: {
body: string;
};
[Endpoint.TEXT]: {
source: LangCodeGoogle<"source">;
target: LangCodeGoogle<"target">;
query: string;
};
[Endpoint.AUDIO]: {
lang: LangCodeGoogle<"target">;
text: string;
textLength: number;
speed: number;
};
};
declare const request: <T extends EndpointType>(endpoint: T, retry?: number) => {
with: (params: Params[T]) => {
promise: Promise<AxiosResponse<any, any>>;
doing: <V>(callback: (res: AxiosResponse<V, any>) => V | undefined) => Promise<V | null>;
};
};
export default request;