No surprise, route use Express behind the scene :-)
const $ = require('betiny-core')
Common arguments and parameters.
Arguments | Description |
---|---|
path | mandatory Any valid path using the same pattern as Express |
options | optional A JSON configuration. See middleware |
callback | mandatory The callback method |
Maybe the most common usage :)
$.route.get("/", (req, res, next) => {
res.send("Yeahhh")
})
Post ...
$.route.post("/", (req, res, next) => {
res.send("Yeahhh")
})
Update ...
$.route.put("/", (req, res, next) => {
res.send("Yeahhh")
})
Remove ...
$.route.delete("/", (req, res, next) => {
res.send("Yeahhh")
})
To delivery static assets ...
$.route.static("/demo", __dirname + "/demo")
An arguments is available to list all routes usage:
yarn start routes:list
You can refine the list based on second arguments:
yarn start routes:list method:get