[Pkg-javascript-commits] [node-vhost] 04/08: Imported Upstream version 3.0.0

Leo Iannacone l3on-guest at moszumanska.debian.org
Sat Oct 11 17:36:35 UTC 2014


This is an automated email from the git hooks/post-receive script.

l3on-guest pushed a commit to branch master
in repository node-vhost.

commit d83ee9bb0c6174cba8bb8f4abfd672da905a69fc
Author: Leo Iannacone <l3on at ubuntu.com>
Date:   Sat Oct 11 19:24:44 2014 +0200

    Imported Upstream version 3.0.0
---
 .npmignore   |  2 --
 HISTORY.md   |  5 +++++
 LICENSE      | 23 +++++++++++++++++++++++
 README.md    | 47 +++++++++++++++++++----------------------------
 index.js     | 51 +++++++++------------------------------------------
 package.json | 17 +++++++++++------
 test/test.js | 22 +++-------------------
 7 files changed, 70 insertions(+), 97 deletions(-)

diff --git a/.npmignore b/.npmignore
deleted file mode 100644
index fcf9ef9..0000000
--- a/.npmignore
+++ /dev/null
@@ -1,2 +0,0 @@
-coverage/
-test/
diff --git a/HISTORY.md b/HISTORY.md
index 848399e..d43a873 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,3 +1,8 @@
+3.0.0 / 2014-08-29
+==================
+
+  * Remove support for sub-http servers; use the `handle` function
+
 2.0.0 / 2014-06-08
 ==================
 
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..39caac6
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,23 @@
+(The MIT License)
+
+Copyright (c) 2014 Jonathan Ong
+Copyright (c) 2014 Douglas Christopher Wilson
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index e238daf..a8abf3a 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
 # vhost
 
-[![NPM version](https://badge.fury.io/js/vhost.svg)](http://badge.fury.io/js/vhost)
-[![Build Status](https://travis-ci.org/expressjs/vhost.svg?branch=master)](https://travis-ci.org/expressjs/vhost)
-[![Coverage Status](https://img.shields.io/coveralls/expressjs/vhost.svg?branch=master)](https://coveralls.io/r/expressjs/vhost)
-
-Previously `connect.vhost()`.
+[![NPM Version][npm-image]][npm-url]
+[![NPM Downloads][downloads-image]][downloads-url]
+[![Build Status][travis-image]][travis-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
+[![Gratipay][gratipay-image]][gratipay-url]
 
 ## Install
 
@@ -88,7 +88,7 @@ var mainapp = connect()
 // create app that will server user content from public/{username}/
 var userapp = connect()
 
-userapp.user(function(req, res, next){
+userapp.use(function(req, res, next){
   var username = req.vhost[0] // username is the "*"
 
   // pretend request was for /{username}/* for file serving
@@ -107,31 +107,22 @@ app.use(vhost('userpages.local', mainapp))
 app.use(vhost('www.userpages.local', mainapp))
 
 // listen on all subdomains for user pages
-app.use(vhost('*.userpages.local', userapp)
+app.use(vhost('*.userpages.local', userapp))
 
 app.listen(3000)
 ```
 
 ## License
 
-The MIT License (MIT)
-
-Copyright (c) 2014 Jonathan Ong me at jongleberry.com
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+[MIT](LICENSE)
+
+[npm-image]: https://img.shields.io/npm/v/vhost.svg?style=flat
+[npm-url]: https://npmjs.org/package/vhost
+[travis-image]: https://img.shields.io/travis/expressjs/vhost.svg?style=flat
+[travis-url]: https://travis-ci.org/expressjs/vhost
+[coveralls-image]: https://img.shields.io/coveralls/expressjs/vhost.svg?style=flat
+[coveralls-url]: https://coveralls.io/r/expressjs/vhost
+[downloads-image]: https://img.shields.io/npm/dm/vhost.svg?style=flat
+[downloads-url]: https://npmjs.org/package/vhost
+[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg?style=flat
+[gratipay-url]: https://gratipay.com/dougwilson/
diff --git a/index.js b/index.js
index 60059e5..eb87bcc 100644
--- a/index.js
+++ b/index.js
@@ -1,42 +1,31 @@
-
 /*!
  * vhost
- * Copyright(c) 2010 Sencha Inc.
- * Copyright(c) 2011 TJ Holowaychuk
  * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2014 Douglas Christopher Wilson
  * MIT Licensed
  */
 
 /**
- * vhost:
- *
- *   Setup vhost for the given `hostname` and `server`.
- *
- *     connect()
- *       .use(connect.vhost('foo.com', fooApp))
- *       .use(connect.vhost('bar.com', barApp))
- *       .use(connect.vhost('*.com', mainApp))
- *
- *  The `server` may be a Connect server, a callable function,
- *  or a regular Node `http.Server`.
+ * Create a vhost middleware.
  *
  * @param {string|RegExp} hostname
- * @param {function|Server} server
+ * @param {function} handle
  * @return {Function}
  * @api public
  */
 
-module.exports = function vhost(hostname, server){
+module.exports = function vhost(hostname, handle) {
   if (!hostname) {
     throw new TypeError('argument hostname is required')
   }
 
-  if (!server) {
-    throw new Error('argument server is required')
+  if (!handle) {
+    throw new TypeError('argument handle is required')
   }
 
-  // create a handle for the server
-  var handle = createHandle(server)
+  if (typeof handle !== 'function') {
+    throw new TypeError('argument handle must be a function')
+  }
 
   // create regular expression for hostname
   var regexp = hostregexp(hostname)
@@ -57,28 +46,6 @@ module.exports = function vhost(hostname, server){
 };
 
 /**
- * Create handle to server.
- *
- * @param {function|Server} server
- * @return {function}
- * @api private
- */
-
-function createHandle(server){
-  if (typeof server === 'function') {
-    // callable servers are the handle
-    return server
-  } else if (typeof server.emit === 'function') {
-    // emit request event on server
-    return function handle(req, res) {
-      server.emit('request', req, res)
-    }
-  }
-
-  throw new TypeError('argument server is unsupported')
-}
-
-/**
  * Get hostname of request.
  *
  * @param (object} req
diff --git a/package.json b/package.json
index d293205..07a52b0 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "vhost",
   "description": "virtual domain hosting",
-  "version": "2.0.0",
+  "version": "3.0.0",
   "author": "Jonathan Ong <me at jongleberry.com> (http://jongleberry.com)",
   "contributors": [
     "Douglas Christopher Wilson <doug at somethingdoug.com>"
@@ -9,17 +9,22 @@
   "license": "MIT",
   "repository": "expressjs/vhost",
   "devDependencies": {
-    "istanbul": "0.2.10",
-    "mocha": "~1.20.1",
+    "istanbul": "0.3.0",
+    "mocha": "~1.21.4",
     "should": "~4.0.1",
     "supertest": "~0.13.0"
   },
+  "files": [
+    "LICENSE",
+    "HISTORY.md",
+    "index.js"
+  ],
   "engines": {
     "node": ">= 0.8.0"
   },
   "scripts": {
-    "test": "mocha --reporter dot test/",
-    "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/",
-    "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec test/"
+    "test": "mocha --reporter spec --bail --check-leaks test/",
+    "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
+    "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
   }
 }
diff --git a/test/test.js b/test/test.js
index 779606f..d1b442c 100644
--- a/test/test.js
+++ b/test/test.js
@@ -93,21 +93,17 @@ describe('vhost(hostname, server)', function(){
       })
     })
 
-    describe('server', function(){
+    describe('handle', function(){
       it('should be required', function(){
-        vhost.bind(null, 'loki.com').should.throw(/server.*required/)
+        vhost.bind(null, 'loki.com').should.throw(/handle.*required/)
       })
 
       it('should accept function', function(){
         vhost.bind(null, 'loki.com', function(){}).should.not.throw()
       })
 
-      it('should accept http server', function(){
-        vhost.bind(null, 'loki.com', http.createServer()).should.not.throw()
-      })
-
       it('should reject plain object', function(){
-        vhost.bind(null, 'loki.com', {}).should.throw(/server.*unsupported/)
+        vhost.bind(null, 'loki.com', {}).should.throw(/handle.*function/)
       })
     })
   })
@@ -213,18 +209,6 @@ describe('vhost(hostname, server)', function(){
       .expect(200, '[["0","bob"],["1","foo"],["host","user-bob.foo.com:8080"],["hostname","user-bob.foo.com"],["length",2]]', done)
     })
   })
-
-  describe('server', function(){
-    it('should support http.Servers', function(done){
-      var loki = http.createServer(function(req, res){ res.end('loki') })
-      var app = createServer('loki.com', loki)
-
-      request(app)
-      .get('/')
-      .set('Host', 'loki.com')
-      .expect('loki', done)
-    })
-  })
 })
 
 function createServer(hostname, server) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-vhost.git



More information about the Pkg-javascript-commits mailing list