> For the complete documentation index, see [llms.txt](https://octoris.gitbook.io/octoris/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://octoris.gitbook.io/octoris/router-api/composeroutes.md).

# 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                  |

{% hint style="info" %}
Middleware run at this level is considered global middleware, meaning it will be ran before ANY route is called on.
{% endhint %}

## Options

```javascript
{
  logger: false
}
```

## Usage

```javascript
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])
```
