[node] begin the great typescript rewrite
This commit is contained in:
parent
3b61a9694d
commit
d668eac4a6
31 changed files with 879 additions and 666 deletions
32
nodejs/model/api.ts
Normal file
32
nodejs/model/api.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
export type APIError = {
|
||||
apiError: 'APIError';
|
||||
error: string;
|
||||
code: number;
|
||||
data: any; // TODO
|
||||
};
|
||||
|
||||
export type Meta = {
|
||||
limit: number;
|
||||
page: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export type Request = {
|
||||
endpoint: string; // the path part of the url to call
|
||||
method?: string; // HTTP method for `fetch` call, defaults to 'GET'
|
||||
page?: number; // run a paginated request starting from this page until all the following pages are fetched
|
||||
payload?: { [key:string]: any}; // optional json object that will be sent along the request
|
||||
priority?: number; // optional priority value, defaults to 10. lower than 10 means the message will be sent faster
|
||||
};
|
||||
|
||||
export type RequestPromise<T> = {
|
||||
reject: (reason?: any) => void;
|
||||
request: Request;
|
||||
resolve: (value: Response<T> | PromiseLike<Response<T>>) => void;
|
||||
};
|
||||
|
||||
export type Response<T> = {
|
||||
data: T;
|
||||
error?: APIError;
|
||||
meta?: Meta;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue