0.1.5 • Published 9 years ago
koa-mountify v0.1.5
koa-mountify
Mount directory as middleware.
**/*.js
will be required and mounted according to path.
Inspired by express-enrouten and koa-mount.
install
$ npm install --save koa-mountify
example
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.
options
mountify(dir);
mountify(path, dir);
/pathname/index.js
will be mounted to/pathname/
- module in
dir
MUST retrun amiddleware
orarray of middleware
.
develop
debug
$ DEBUG=koa-mountify node --harmony example/app.js
test
$ npm test
coverage
$ npm run cover
license
MIT