Skip to content

Commit

Permalink
Fix HandleFunction typing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime LUCE committed Oct 21, 2015
1 parent d90b63e commit 962ede5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions connect/connect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ declare module "connect" {

module createServer {
export type ServerHandle = HandleFunction | http.Server;
export type HandleFunction = (req: http.IncomingMessage, res: http.ServerResponse, next: Function) => void;


export interface HandleFunction {
(req: http.IncomingMessage, res: http.ServerResponse): void;
(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void;
(err: Error, req: http.IncomingMessage, res: http.ServerResponse, next: Function): void;
}

export interface ServerStackItem {
route: string;
handle: ServerHandle;
}

export interface Server extends NodeJS.EventEmitter {
(req: http.IncomingMessage, res: http.ServerResponse, next: Function) => void;

route: string;
stack: ServerStackItem[];

/**
* Utilize the given middleware `handle` to the given `route`,
* defaulting to _/_. This "route" is the mount-point for the
Expand All @@ -44,16 +49,15 @@ declare module "connect" {
*/
use(fn: HandleFunction): Server;
use(route: string, fn: HandleFunction): Server;

/**
* Handle server requests, punting them down
* the middleware stack.
*
* @private
*/
handle(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void;



/**
* Listen for connections.
*
Expand Down

0 comments on commit 962ede5

Please sign in to comment.