bustardcelly/caddis — pull request #6 by rajit (2014-03-19 19:41:20+00:00)
Title: Make caddis usable as a direct require(...)

We want to use caddis directly in tests, rather than starting it externally, writing files to ~/.caddis and needing to manage it with forever. So this pull request will let you do something like this:

```js
var caddis = require('caddis');

// ... mocha code ...
before(function (done) { caddis.listen(8080, done) });
```

And then interact with it as normal with `request`, or something like it. All the existing tests still pass, except now it can be used in this further way.

Commit details:
* Moved old lib/caddis.js to lib/caddis/shell.js, to clearly identify as shell and ~/.caddis-related code
* Created new lib/caddis.js to give access to clearly exported .shell and .listen
* Wrap lib/caddis/server.js in function { } and export it so that the caddis server is directly usable
* Add parameters to exported server function so that port can directly be configured, options can be passed to disable/enable logging and a callback can be passed which will be called on completion of server startup