Skip to content

Commit

Permalink
Merge pull request #223 from mike-north/typescript
Browse files Browse the repository at this point in the history
TypeScript type definitions
  • Loading branch information
mike-north committed Jan 9, 2018
2 parents fc363b3 + 6036a06 commit 0e8df8d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
37 changes: 37 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import FakeXMLHttpRequest from "fake-xml-http-request";
import { Params, QueryParams } from "route-recognizer";
type SetupCallback = (this: Server) => void;
interface SetupConfig {
forcePassthrough: boolean;
}
export type Config = SetupCallback | SetupConfig;
export class Server {
// HTTP request verbs
public get: RequestHandler;
public put: RequestHandler;
public post: RequestHandler;
public patch: RequestHandler;
public delete: RequestHandler;
public options: RequestHandler;
public head: RequestHandler;
constructor(setup?: SetupCallback);

public shutdown(): void;
}

export type RequestHandler = (
urlExpression: string,
response: ResponseHandler,
async?: boolean
) => void;

export type ResponseData = [number, { [k: string]: string }, string];
interface ExtraRequestData {
params: Params;
queryParams: QueryParams;
}
export type ResponseHandler = (
request: FakeXMLHttpRequest | ExtraRequestData
) => ResponseData | PromiseLike<ResponseData>;

export default Server;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pretender",
"version": "1.6.1",
"version": "2.0.0",
"main": "./pretender.js",
"license": "MIT",
"scripts": {
Expand Down Expand Up @@ -34,7 +34,7 @@
"sinon": "^3.2.1"
},
"dependencies": {
"fake-xml-http-request": "^1.6.0",
"fake-xml-http-request": "^2.0.0",
"route-recognizer": "^0.3.3"
},
"jspm": {
Expand Down

0 comments on commit 0e8df8d

Please sign in to comment.