-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90574e5
commit 88bfbef
Showing
8 changed files
with
34 additions
and
28 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 |
---|---|---|
@@ -1,29 +1,29 @@ | ||
/// <reference types="express" /> | ||
import { Request, Response, RequestHandler, NextFunction } from 'express'; | ||
export interface IRoute<TRequest, TResponse> { | ||
import * as Express from 'express'; | ||
export interface IRoute<TRequest extends Express.Request, TResponse extends Express.Response> { | ||
readonly path: string; | ||
use(...handler: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
get(...handler: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
post(...handler: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
patch(...handler: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
put(...handler: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
delete(...handler: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
use(...handler: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
get(...handler: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
post(...handler: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
patch(...handler: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
put(...handler: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
delete(...handler: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
handlers: { | ||
[method: string]: RequestHandler[]; | ||
[method: string]: Express.RequestHandler[]; | ||
}; | ||
} | ||
export declare class Route<TRequest extends Request, TResponse extends Response> implements IRoute<TRequest, TResponse> { | ||
export declare class Route<TRequest extends Express.Request, TResponse extends Express.Response> implements IRoute<TRequest, TResponse> { | ||
readonly path: string; | ||
private _handlers; | ||
constructor(path: string); | ||
readonly handlers: { | ||
[index: string]: ((req: TRequest, res: TResponse, next?: NextFunction) => void)[]; | ||
[index: string]: ((req: TRequest, res: TResponse, next?: Express.NextFunction) => void)[]; | ||
}; | ||
use(...handlers: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
get(...handlers: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
post(...handlers: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
patch(...handlers: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
put(...handlers: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
delete(...handlers: Array<(req: TRequest, res: TResponse, next?: NextFunction) => any>): this; | ||
use(...handlers: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
get(...handlers: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
post(...handlers: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
patch(...handlers: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
put(...handlers: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
delete(...handlers: Array<(req: TRequest, res: TResponse, next?: Express.NextFunction) => any>): this; | ||
private handle(method, ...handlers); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/// <reference types="express" /> | ||
import { Router as ExpressRouter, NextFunction, Request, Response } from 'express'; | ||
import * as Express from 'express'; | ||
import { IRoute } from './route'; | ||
export declare class Router<TRequest extends Request, TResponse extends Response> { | ||
export declare class Router<TRequest extends Express.Request, TResponse extends Express.Response> { | ||
private _stack; | ||
private _extendRequest; | ||
private _extendResponse; | ||
private _handler; | ||
constructor(extendRequest: (req: Request) => TRequest, extendResponse: (req: Response) => TResponse); | ||
constructor(handler?: (req: Request, res: Response, next?: NextFunction) => void); | ||
constructor(handler?: (req: Request, res: Response, next?: Express.NextFunction) => void); | ||
route(path: string): IRoute<TRequest, TResponse>; | ||
getRouter(): ExpressRouter; | ||
getRouter(): Express.Router; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
export { Router } from './express/router'; | ||
import { Router as CoreRouter, Request, Response } from 'express'; | ||
import { Router } from './express/router'; | ||
export default Router; | ||
export { Router, CoreRouter, Request, Response }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.