Last active
July 31, 2017 20:08
Sdktor flow type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'sdktor' { | |
declare export type Response<T> = { body: T, status: number }; | |
declare export type AsyncResponse<T> = Promise<Response<T>>; | |
declare type BeforeSend = (reqConfig: {| | |
path: string, | |
params: Object, | |
headers: Object, | |
|}) => {| | |
path: string, | |
params: Object, | |
headers: Object, | |
|}; | |
declare type PostRequest = ( | |
res: Response<*>, | |
ok: boolean | |
) => Response<*>; | |
declare export type Hooks = { | |
beforeSend?: Array<BeforeSend>, | |
postRequest?: Array<PostRequest>, | |
}; | |
declare type Factory = ( | |
url: string, | |
headers?: Object, | |
options?: Hooks | |
) => Sdktor; | |
declare type Verb = ( | |
path: string, | |
headers?: Object | |
) => (params: ?Object) => AsyncResponse<*>; | |
declare export type Sdktor = {| | |
+at: Factory, | |
+get: Verb, | |
+post: Verb, | |
+put: Verb, | |
+del: Verb, | |
+patch: Verb, | |
+url: () => string, | |
|}; | |
declare export default Factory; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment