servie-vhost
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

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

Package Sidebar

Install

npm i servie-vhost

Weekly Downloads

4

Version

2.0.2

License

Apache-2.0

Unpacked Size

15.9 kB

Total Files

9

Last publish

Collaborators

  • blakeembrey