Mount directory as middleware.
**/*.js
will be required and mounted according to path.
Inspired by express-enrouten and koa-mount.
$ npm install --save koa-mountify
var koa = require("koa");
var app = koa();
var join = require("path").join;
var mountify = require("koa-mountify");
app.use(mountify(join(__dirname, "route")));
// similar to
// var mount = require("koa-mount");
// app.use(mount("/", require("./route/index")));
// app.use(mount("/foo", require("./route/foo")));
// app.use(mount("/foo/bar", require("./route/foo/bar")));
View the examples directory for working examples.
mountify(dir);
mountify(path, dir);
-
/pathname/index.js
will be mounted to/pathname/
- module in
dir
MUST retrun amiddleware
orarray of middleware
.
$ DEBUG=koa-mountify node --harmony example/app.js
$ npm test
$ npm run cover
MIT