-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from mike-north/typescript
TypeScript type definitions
- Loading branch information
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
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
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; |
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