Skip to content

Commit

Permalink
Merge pull request #128 from groupon/type-register
Browse files Browse the repository at this point in the history
fix: export type for registerEndpoints
  • Loading branch information
dbushong committed Feb 28, 2022
2 parents 17e0fd4 + 048b809 commit 4eedab7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/typedefs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ type BodyMethods = {

type FetchResponse = Promise<IncomingMessage & BodyMethods> & BodyMethods;

type Fetch = (path: string, opts?: Gofer.FetchOpts, cb?: any) => FetchResponse;

type EndpointFnReturn =
| ((...args: any[]) => FetchResponse)
| {
[key: string]: (...args: any[]) => FetchResponse;
};

export type EndpointFn = (fetch: Fetch) => EndpointFnReturn;

declare class Gofer {
constructor(
config: { [name: string]: Gofer.Opts },
Expand All @@ -23,12 +33,14 @@ declare class Gofer {
defaults?: Gofer.FetchOpts,
options?: Gofer.FetchOpts
): Gofer.FetchOpts;
registerEndpoint(name: string, endpointFn: EndpointFn): this;
registerEndpoints(endpoints: { [name: string]: EndpointFn }): this;

clone(): this;

with(opts: Gofer.Opts): this;

fetch(path: string, opts?: Gofer.FetchOpts): FetchResponse;
fetch: Fetch;
get(path: string, opts?: Gofer.FetchOpts): FetchResponse;
post(path: string, opts?: Gofer.FetchOpts): FetchResponse;
put(path: string, opts?: Gofer.FetchOpts): FetchResponse;
Expand Down

0 comments on commit 4eedab7

Please sign in to comment.