2.0.2 • Published 5 years ago

servie-vhost v2.0.2

Weekly downloads
6
License
Apache-2.0
Repository
github
Last release
5 years ago

Servie Vhost

NPM version NPM downloads Build status Test coverage

Simple virtual host middleware for Servie.

Installation

npm install servie-vhost --save

Usage

import { vhost, getHostFromUrl } from "servie-vhost";
import { compose } from "throwback";

const app = compose([
  vhost("admin.example.com", function(req) {
    return send(req, "Welcome to admin!");
  }),
  vhost(":subdomain.example.com", function(req) {
    return send(req, `Welcome to ${req.vhost[0]} subdomain!`);
  })
]);

For projects whose host is not in the header, they can switch between exported getHostFromHeader and getHostFromUrl functions, or define their own, as the third argument to vhost(hostname, fn, getHost).

TypeScript

This project is written using TypeScript and publishes the definitions directly to NPM.

License

Apache 2.0