# koa-mount-dir

> Routing lib for Koa

Latest version **0.2.1** (published 2014-08-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-mount-dir
pnpm add koa-mount-dir
yarn add koa-mount-dir
bun add koa-mount-dir
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2014-08-26 |
| First published | 2014-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+6 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Pavel Silin |
| Maintainers | fi11 |
| Keywords | koa, routing |

## Links

- npm: https://www.npmjs.com/package/koa-mount-dir
- Repository: https://github.com/fi11/koa-mount-dir
- Issues: https://github.com/fi11/koa-mount-dir/issues
- npm.io page: https://npm.io/package/koa-mount-dir

## Dependencies (5)

- [debug](https://npm.io/package/debug.md) ~0.8.1
- [basic-auth](https://npm.io/package/basic-auth.md) 0.0.1
- [jsonschema](https://npm.io/package/jsonschema.md) ~1.0.0
- [koa-router](https://npm.io/package/koa-router.md) ~3.1.3
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ~0.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

- 0.2.1 (latest) — 2014-08-26
- 0.2.0 — 2014-08-25
- 0.1.0 — 2014-05-28
- 0.0.1 — 2014-05-10
- 0.0.0 — 2014-05-08

## README

Simple routing lib for [Koa](https://github.com/koajs/koa) based on
[this](https://github.com/koajs/api-boilerplate/blob/master/lib/load.js) code.

## Installation

```
$ npm install koa-mount-dir
```

## Example

File structure:
```
- api
  - users
    - config.json
    - index.js
- pages
  - home
    - config.json
    - index.js
- app.js
```
In config.json:
```json
{
    "routes": {
        "GET /path/to/": "detail"
    }
}
```
Where "GET /path/to/" is http method with routing path and "detail" is handler name witch exports in index.js

index.js source:
```js
exports.detail = function *() { this.body = 'ok' }
```

app.js source:
```js
var koa = require('koa');
var app = koa();

var mountPages = require('koa-mount-dir')('pages');

// first argument "api" is path to mount dir and second argument is prefix to path ('/users/' -> /api/v1/users/)
var mountApi = require('koa-mount-dir')('api', '/api/v1');

// for mount ./api dir with path prefix "/api/v1"
mountApi(app);

// for mount ./pages dir
mountPages(app);

app.listen(8000);
```

For running example

```
$ make example
```

## Running tests

```
$ make test
```

## Authors

  - [Pavel Silin](https://github.com/fi11)

# License

  MIT

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