Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ export declare interface App {
[namespace: string]: HandlerFunction;
}

export declare type Middleware = (req: Request, res: Response, next: Middleware) => void;
export declare type ErrorHandlingMiddleware = (error: Error, req: Request, res: Response, next: ErrorHandlingMiddleware) => void;
export declare type Middleware = (req: Request, res: Response, next: NextFunction) => void;
export declare type ErrorHandlingMiddleware = (error: Error, req: Request, res: Response, next: NextFunction) => void;
export declare type ErrorCallback = (error?: Error) => void;
export declare type RoutingFunction = (api: API, opts?: object) => void;
export declare type HandlerFunction = (req?: Request, res?: Response, next?: NextFunction) => void | {} | Promise<{}>;
export declare type LoggerFunction = (message: string) => void;
export declare type NextFunction = () => void;
Expand Down Expand Up @@ -96,6 +97,18 @@ export declare interface Options {
version?: string;
}

export declare interface RegisterOptions extends Options {
prefix?: string;
}

export declare interface Route {
vars: {[key: string]: string};
stack: HandlerFunction[];
inherited?: HandlerFunction[];
route: string;
path: string;
}

export declare class Request {
app: API;
version: string;
Expand Down Expand Up @@ -203,6 +216,8 @@ export declare class API {
use (...errorHandlingMiddleware: ErrorHandlingMiddleware[]);

finally(callback: FinallyFunction): void;

register(fn: RoutingFunction, opts?: RegisterOptions): void;

run(event: APIGatewayEvent, context: Context, cb: (err: Error, result: any) => void): void;
run(event: APIGatewayEvent, context: Context): Promise<any>;
Expand Down