forked from silvermine/lambda-express
-
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.
feat: Add Router
route
method (silvermine#19)
- Loading branch information
Showing
4 changed files
with
219 additions
and
6 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,53 @@ | ||
import { IRoute, PathParams, ProcessorOrProcessors } from './interfaces'; | ||
import Router from './Router'; | ||
|
||
export default class Route implements IRoute { | ||
|
||
protected _router: Router; | ||
|
||
public constructor(path: PathParams, parentRouter: Router) { | ||
this._router = new Router(parentRouter.routerOptions); | ||
parentRouter.addSubRouter(path, this._router); | ||
} | ||
|
||
public all(...handlers: ProcessorOrProcessors[]): this { | ||
this._router.all('/', ...handlers); | ||
return this; | ||
} | ||
|
||
public head(...handlers: ProcessorOrProcessors[]): this { | ||
this._router.head('/', ...handlers); | ||
return this; | ||
} | ||
|
||
public get(...handlers: ProcessorOrProcessors[]): this { | ||
this._router.get('/', ...handlers); | ||
return this; | ||
} | ||
|
||
public post(...handlers: ProcessorOrProcessors[]): this { | ||
this._router.post('/', ...handlers); | ||
return this; | ||
} | ||
|
||
public put(...handlers: ProcessorOrProcessors[]): this { | ||
this._router.put('/', ...handlers); | ||
return this; | ||
} | ||
|
||
public delete(...handlers: ProcessorOrProcessors[]): this { | ||
this._router.delete('/', ...handlers); | ||
return this; | ||
} | ||
|
||
public patch(...handlers: ProcessorOrProcessors[]): this { | ||
this._router.patch('/', ...handlers); | ||
return this; | ||
} | ||
|
||
public options(...handlers: ProcessorOrProcessors[]): this { | ||
this._router.options('/', ...handlers); | ||
return this; | ||
} | ||
|
||
} |
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
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
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