feathersjs/feathers — pull request #33 by daffl (2014-01-04 03:06:04+00:00)
Title: Add app.setup() to support HTTPS

This pull request adds an `app.setup(server)` method to allow setting up a Feathers application with a different server than the on used in `app.listen`. This closes #25 and allows to easily use HTTPS servers and virtual hosts for both, SocketIO and REST, as added to the documentation:

__HTTPS__

With your Feathers application initialized it is easy to set up an HTTPS REST and SocketIO server:

```js
app.configure(feathers.socketio()).use('/todos', todoService);

var https = require('https');
var server = https.createServer({
key: fs.readFileSync('privatekey.pem'),
cert: fs.readFileSync('certificate.pem')
}, app).listen(443);

// Call app.setup to initialize all services and SocketIO
app.setup(server);
```

__Virtual Hosts__

You can use `feathers.vhost` (which is the same as [Express and Connect .vhost](http://www.senchalabs.org/connect/vhost.html)) to run your Feathers app on a virtual host:

```js
app.use('/todos', todoService);

var host = feathers().use(feathers.vhost('foo.com', app));
var server = host.listen(8080);

// Here we need to call app.setup because .listen on our virtal hosted
// app is never called
app.setup(server);
```

Also adds an `app.service(path, service)` convenience method as suggested by @whitecolor in #22 (`app.use(path, service)` will still work).