# multihost

> Hosting multiple Express apps on the same server.

Latest version **0.1.1** (published 2016-04-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install multihost
pnpm add multihost
yarn add multihost
bun add multihost
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2016-04-17 |
| First published | 2016-04-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Cheton Wu |
| Maintainers | cheton |
| Keywords | connect, express, multihost, vhost |

## Links

- npm: https://www.npmjs.com/package/multihost
- Repository: https://github.com/cheton/multihost
- Issues: https://github.com/cheton/multihost/issues
- npm.io page: https://npm.io/package/multihost

## Recent versions

- 0.1.1 (latest) — 2016-04-17
- 0.1.0 — 2016-04-17

## README

# multihost [![build status](https://travis-ci.org/cheton/multihost.svg?branch=master)](https://travis-ci.org/cheton/multihost) [![Coverage Status](https://coveralls.io/repos/cheton/multihost/badge.svg?branch=master&service=github)](https://coveralls.io/github/cheton/multihost?branch=master)

[![NPM](https://nodei.co/npm/multihost.png?downloads=true&stars=true)](https://nodei.co/npm/multihost/)  

Hosting multiple Express apps on the same server.

## Installation
```bash
$ npm install --save multihost
```

## API

```js
var multihost = require('multihost')
```

### multihost(options)

Returns a middleware to host an Express application.

#### Options

The function takes an option `options` object that may contain any of the following keys:

##### hosts

A virtual host string or an array of virtual host strings.

##### route

A route string containing the URI to be matched.

##### server

An Express app as shown below:
```js
var app = express();
```

## Example
```js
var app = express();
var fooApp = express();
var barApp = express();
var mainApp = express();
var multihost = require('multihost');

app.use(multihost({
    hosts: 'foo.com',
    server: fooApp
}));

app.use(multihost({
    hosts: 'bar.com',
    server: barApp
}));

app.use(multihost({
    hosts: '*.com',
    route: '/foo',
    server: fooApp
}));

app.use(multihost({
    hosts: '*.com',
    route: '/bar',
    server: barApp
}));

app.use(multihost({
    hosts: [
        '*.com',
        'localhost'
    ],
    server: mainApp
}));
```

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/multihost · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
