# koa-router-plus

> koa router with simple controller

Latest version **1.0.5** (published 2016-12-28) · MIT license · 0 weekly downloads

## Install

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

## 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.0.5 |
| Published | 2016-12-28 |
| First published | 2016-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | shifuture |
| Maintainers | shifuture |
| Keywords | koa, router, controller |

## Links

- npm: https://www.npmjs.com/package/koa-router-plus
- Repository: https://github.com/shifuture/koa-router-plus
- Homepage: https://github.com/shifuture/koa-router-plus#readme
- Issues: https://github.com/shifuture/koa-router-plus/issues
- npm.io page: https://npm.io/package/koa-router-plus

## Dependencies (5)

- [fs](https://npm.io/package/fs.md) 0.0.2
- [path](https://npm.io/package/path.md) ^0.12.7
- [async](https://npm.io/package/async.md) ^2.0.0-rc.3
- [debug](https://npm.io/package/debug.md) ^2.2.0
- [koa-router](https://npm.io/package/koa-router.md) ^5.4.0

## 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.0.5 (latest) — 2016-12-28
- 1.0.4 — 2016-12-12
- 1.0.3 — 2016-10-31
- 1.0.2 — 2016-04-29
- 1.0.1 — 2016-04-29

## README

# koa-router-plus

> Create controller and attach related router 

## Thanks To

- [Koa.js](https://github.com/koajs/koa)
- [koa-simple-controller](https://github.com/mrangelmarino/koa-simple-controller/)
- [koa-router](https://github.com/alexmingoia/koa-router)

Idea comes from koa-router and koa-simple-controller

## Installation

Install using [npm](https://www.npmjs.org/):

```sh
npm install koa-router-plus --save
```


## Usage

### index.js

```javascript
'use strict';

var app = require('koa')();
var router = require('koa-router-plus')();

app.use(router.initialCtrl());
app.use(router.routes());
app.listen(3000);
```

### lib/controller/index.js

```javascript
module.exports = {
    index : function(ctx) {
        ctx.body='Welcome to drink bar, What kind of drink do you like?'
    },
    
}
```

### lib/controller/help/coffee.js

```javascript
module.exports = {
    index : function(ctx) {
        ctx.body='Hello, What kind of coffee do you like?'
    },
    
    moreSugar: function(ctx) {
        ctx.body='Sugar, please!'
    },

    moreMilk: function(ctx) {
        ctx.body='Milk, please!'
    }
}
```

### lib/controller/help/Tea.js

```javascript
module.exports = {
    index : function(ctx) {
        ctx.body='Hello, What kind of tea do you like?'
    },
    
    hotter: function(ctx) {
        ctx.body='Hey, heat it please!'
    },
}
```

### Browser

URL: http://localhost:3000/, Means call index.index().

URL: http://localhost:3000/help/coffee, Means call help.coffee.index().

URL: http://localhost:3000/help/coffee/moreSugar, Means call help.coffee.moreSugar().

## Contribute
You are welcome to contribute.

## License
[MIT](LICENSE)

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