koa-mount-hot
v2.0.0
Published
Mounting middleware for koa
Downloads
9
Readme
koa-mount-hot
Hot reloading koa-mount
Install
npm i -S koa-mount-hot
Usage
modules
foo
index.js
bar
index.js
// modules/foo/index.js
export const app = koa()
// setup routes, etc.
import mount from 'koa-hot-mount'
const koaApp = koa()
const opts = {
path: 'foo/index',
require: (req) => {
const mod = require(req)
// Configure instantiation of module...
mod.liveApp = app // E.g.
// Return mount point.
return mod
}
}
koaApp.use(mount('/', opts), true)
API
mount(mountPoint, opts)
mount(mountPoint, modulePath)
mount(mountPoint, module)