# koa-combine-routers

> Middleware for composing multiple instances of koa-router.

Latest version **4.0.2** (published 2018-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-combine-routers
pnpm add koa-combine-routers
yarn add koa-combine-routers
bun add koa-combine-routers
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.2 |
| Published | 2018-10-02 |
| First published | 2016-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Saad Quadri |
| Maintainers | saadq |

## Links

- npm: https://www.npmjs.com/package/koa-combine-routers
- npm.io page: https://npm.io/package/koa-combine-routers

## Dependencies (3)

- [koa-compose](https://npm.io/package/koa-compose.md) 4.1.0
- [@types/koa-router](https://npm.io/package/@types/koa-router.md) ^7.0.32
- [@types/koa-compose](https://npm.io/package/@types/koa-compose.md) 3.2.2

## Recent versions

- 4.0.2 (latest) — 2018-10-02
- 1.1.1 (old) — 2018-01-07
- 1.0.0 (next) — 2016-09-02
- 4.0.1 — 2018-06-11
- 4.0.0 — 2018-06-11
- 3.0.1 — 2018-05-02
- 3.0.0 — 2018-04-03
- 2.0.1 — 2018-01-07
- 1.1.0 — 2018-01-07
- 2.0.0 — 2018-01-07
- 0.1.2 — 2016-09-02
- 0.1.1 — 2016-09-02

## README

# koa-combine-routers

[![Build Status](https://travis-ci.org/saadq/koa-combine-routers.svg?branch=master)](https://travis-ci.org/saadq/koa-combine-routers)

Convenience middleware for composing multiple instances of [koa-router](https://github.com/alexmingoia/koa-router).

For usage with Koa 1.X, check out the [`old`](https://github.com/saadq/koa-combine-routers/tree/old) branch.

## Installation

```
$ npm install koa-combine-routers
```

## Usage

**app.js**

```javascript
const Koa = require('koa')
const router = require('./routes')

const app = new Koa()

app.use(router())
```

**routes.js**

```javascript
const Router = require('koa-router')
const combineRouters = require('koa-combine-routers')

const dogRouter = new Router()
const catRouter = new Router()

dogRouter.get('/dogs', async ctx => {
  ctx.body = 'ok'
})

catRouter.get('/cats', async ctx => {
  ctx.body = 'ok'
})

const router = combineRouters(
  dogRouter,
  catRouter
)

module.exports = router
```

## API

| param   | type                      | description                                       |
| ------- | ------------------------- | ------------------------------------------------- |
| routers | `Object[]` \| `...Object` | An array of routers or multiple router arguments. |

#### combineRouters(routers)

#### combineRouters(...routers)

---
_Source: https://npm.io/package/koa-combine-routers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
