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

Package Sidebar

Install

npm i koa-mount-hostname

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • rainder