route-controllers
Use opinionated typescript ES6 classes as express routes.
How to use
app.userouter app.listen3000,
How do I map http methods?
By default we deduce the http method from the name of your method in the controllers
method name | http method | route |
---|---|---|
GetSomething | GET | /GetSomething |
CreateSomething | POST | /CreateSomething |
UpdateSomething | PUT | /UpdateSomething |
DeleteSomething | DELETE | /DeleteSomething |
However you can overwrite our basic method mapper by passing setHttpMethodNameMapper
a function before you GenerateRouter
In the below example we will map all method names starting with delete
to a delete http method, everything else will be a get
http method.
setHttpMethodNameMapper
You can also overwrite a method by using the HttpMethod
decorator: