koa-mount-hostname

0.2.0 • Public • Published

koa-mount-hostname

Mount other Koa applications as middleware on a specific hostname (subdomain).

Installation

$ npm install koa-mount-hostname

Example

const mountHostname = require('koa-mount-hostname');
const koa = require('koa');
 
// hello
 
const a = koa();
 
a.use(function *(next){
  this.body = 'Hello';
});
 
// world
 
const b = koa();
 
b.use(function *(next){
  this.body = 'World';
});
 
// app
 
const app = koa();
 
app.use(mountHostname('www.website1.com', a));
app.use(mountHostname(/^[a-z]+\.website2\.com$/i, b));
 
app.listen(3000);

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.0
    6
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.0
    6
  • 0.1.1
    2
  • 0.1.0
    2

Package Sidebar

Install

npm i koa-mount-hostname

Weekly Downloads

2

Version

0.2.0

License

MIT

Last publish

Collaborators

  • rainder