# koa-jollof-router

> A sane router for koa2+

Latest version **1.1.7** (published 2020-08-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-jollof-router
pnpm add koa-jollof-router
yarn add koa-jollof-router
bun add koa-jollof-router
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.7 |
| Published | 2020-08-03 |
| First published | 2017-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Iyobo Eki |
| Maintainers | iyobo |
| Keywords | koa, router |

## Links

- npm: https://www.npmjs.com/package/koa-jollof-router
- npm.io page: https://npm.io/package/koa-jollof-router

## Dependencies (1)

- [koa-router](https://npm.io/package/koa-router.md) ^7.1.1

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.1.7 (latest) — 2020-08-03
- 1.1.6 — 2019-03-12
- 1.1.5 — 2018-03-19
- 1.1.4 — 2018-02-26
- 1.1.3 — 2017-08-01
- 1.1.2 — 2017-07-24
- 1.1.1 — 2017-05-21
- 1.1.0 — 2017-05-16
- 1.0.0 — 2017-05-14

## README

# Koa-Jollof-Router

A router for KoaJS that makes routing in KoaJS easy to reason about and compose.
Supports Koa@2 and up.

## Features

* Nested Routing

## How to use

```
const KJRouter = require('koa-jollof-router');

const routeMap = {

    '/': { flow: asyncFunc1}, //same as 'get /'
    'get /': {flow: asyncFunc2 }, //Same path as the first one. given name. Will overwrite because it is the last path to be given to 'get /'.
    'get /contact/*': {flow: [ auth.isLoggedIn, auth.canGetContacts, asyncFunc3]}, //wildcard router. Perfect for html5 routing
    'delete /foo/:id': {flow: [ auth.isLoggedIn, auth.canDeleteFoos, asyncFunc4]},
    '/api/v1': { flow: auth.isLoggedIn, children: {
        '/': {flow: ApiIndexPage},
        'patch /post/:id': {flow: [auth.canEditPost, postControllerFunc]}
     }}

}

//
const router = new KJRouter(routeMap);

//Let's extend the routes

const anotherRouteMapFromSomeOtherModule={
    '/contact': {flow: contactPage},
    'post /contact': {flow: sendContactAction}
}

//Appends the second routemap to router's. Will overwrite
router.addRoutes(anotherRouteMapFromSomewhereElse)

// OR to ensure no overwrites

router.addRoutes({
    '/other': { children: anotherRouteMapFromSomeOtherModule}
});



//register routes with Koa. This should be the final step.
app.use(router.routes());

```

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