2.0.0 • Published 8 years ago

koa-mount-hot v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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)

License

MIT