Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cheton/multihost
Hosting multiple Express apps on the same server.
https://github.com/cheton/multihost
Last synced: 10 days ago
JSON representation
Hosting multiple Express apps on the same server.
- Host: GitHub
- URL: https://github.com/cheton/multihost
- Owner: cheton
- License: mit
- Created: 2016-04-17T14:12:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-06-23T02:58:34.000Z (over 8 years ago)
- Last Synced: 2024-10-29T16:57:11.196Z (20 days ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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/github/cheton/multihost/badge.svg?branch=master)](https://coveralls.io/github/cheton/multihost?branch=master)
[![NPM](https://nodei.co/npm/multihost.png?downloads=true&stars=true)](https://www.npmjs.com/package/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)