Methods
getRoutes(dir, files) → {Array.<String>}
Return list of route files for a given directory.
Parameters:
Name | Type | Description |
---|---|---|
dir | String | Files directory. |
files | Array | List of files (optional). |
Returns:
- Type:
- Array.<String>
loadRoutes(router)
Load routes from a pre-configured directory.
Parameters:
Name | Type | Description |
---|---|---|
router | Router | Router instance. |
module:router/Route()
Handle routing operations for the given Route.
- Source
Example
// .. sam-app/src/routes/foo.js
const routeConfig = {
middleware: [middlewareFunc1, middlewareFunc2],
resource: true || ['get', 'put', 'patch', 'submit'],
index (req, res) {},
get (req, res, id) {},
create (req, res) {},
put (req, res, id) {},
update (req, res) {},
patch (req, res, id) {},
post (req, res) {},
submit (req, res, id) {},
delete (req, res, id) {}
};
module.exports = routeConfig;