mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 18:13:25 +00:00
Merge branch 'dev' into pr-14-v2
This commit is contained in:
@@ -5,10 +5,13 @@ export type FetcherOptions = {
|
||||
headers?: Record<string, string>;
|
||||
query?: Record<string, string>;
|
||||
method?: 'HEAD' | 'GET' | 'POST';
|
||||
readHeaders?: string[];
|
||||
body?: Record<string, any> | string | FormData | URLSearchParams;
|
||||
returnRaw?: boolean;
|
||||
};
|
||||
|
||||
// Version of the options that always has the defaults set
|
||||
// This is to make making fetchers yourself easier
|
||||
export type DefaultedFetcherOptions = {
|
||||
baseUrl?: string;
|
||||
body?: Record<string, any> | string | FormData;
|
||||
@@ -16,13 +19,23 @@ export type DefaultedFetcherOptions = {
|
||||
query: Record<string, string>;
|
||||
method: 'HEAD' | 'GET' | 'POST';
|
||||
returnRaw: boolean;
|
||||
readHeaders: string[];
|
||||
};
|
||||
|
||||
export type FetcherResponse<T = any> = {
|
||||
statusCode: number;
|
||||
headers: Headers;
|
||||
finalUrl: string;
|
||||
body: T;
|
||||
};
|
||||
|
||||
// This is the version that will be inputted by library users
|
||||
export type Fetcher<T = any> = {
|
||||
(url: string, ops: DefaultedFetcherOptions): Promise<T>;
|
||||
(url: string, ops: DefaultedFetcherOptions): Promise<FetcherResponse<T>>;
|
||||
};
|
||||
|
||||
// this feature has some quality of life features
|
||||
// This is the version that scrapers will be interacting with
|
||||
export type UseableFetcher<T = any> = {
|
||||
(url: string, ops?: FetcherOptions): Promise<T>;
|
||||
full: (url: string, ops?: FetcherOptions) => Promise<FetcherResponse<T>>;
|
||||
};
|
||||
|
Reference in New Issue
Block a user