composeRoutes
One of the most important functions within the framework, takes a list of routes and composes them into a single function for the server
Arguments
Name
Type
Description
opts
Object
The options object to apply to the octoris server
routes
Map[]
The routing tree built out by the route functions
middleware
Function[]
An array of middleware functions
Options
{
logger: false
}
Usage
const { router, methods, response } = require('octoris')
function homeHandler () {
return response.send(200, 'Hello Home!')
}
function aboutHandler () {
return response.send(200, 'Hello About!')
}
const home = router.route([router.fixed('/')], [
methods.GET(homeHandler)
])
const about = router.route([router.fixed('about')], [
methods.GET(aboutHandler)
])
const routes = router.composeRoutes({ logger: true }, [about, home])
Last updated
Was this helpful?