Merge branch 'refactor/config' into 0.3

This commit is contained in:
Ritchie Martori
2012-03-08 11:35:24 -07:00
6 changed files with 47 additions and 11 deletions

View File

@@ -15,7 +15,20 @@ Extensible, distributed resource server.
$ [sudo] npm install deployd -g
## CLI
## Starting / Stopping
You can start and stop the server with the `dpd` CLI or with the node module.
var dpd = require('deployd')
.use('http://localhost:3333')
// optionally specify which storage resource to use
// currently only mongodb is supported
.storage('mongodb://localhost/my-dpd-storage')
// tell deployd to listen
.listen()
;
or
$ dpd
$ deployd is running at http://localhost:2304

View File

@@ -4,6 +4,12 @@
var dpd = require('mdoq')
/**
* Export a method to change the storage resource.
*/
dpd.storage = require('./storage').storage
/**
* Export the dpd mdoq object as the public interface.
*/

View File

@@ -32,7 +32,6 @@ module.exports = function (req, res, next, end) {
next();
})
}
});
} else {
return next(new Error('The provided module is not supported'));

23
lib/storage.js Normal file
View File

@@ -0,0 +1,23 @@
/**
* Dependencies
*/
var url = 'localhost/deployd';
module.exports = require('mdoq')
.use(function (req, res, next) {
var path = req.resource && req.resource.path;
this.url = url + (path || this.url);
next();
})
.require('mdoq-mongodb')
;
/**
* Export a way to change the storage url.
*/
module.exports.storage = function (db) {
url = db;
return this;
};

View File

@@ -3,11 +3,6 @@ function format(name) {
return '/' + name;
}
module.exports = require('mdoq')
.use(function (req, res, next) {
var path = req.resource && req.resource.path;
this.url = 'localhost/deployd' + (path || this.url);
next();
})
.require('mdoq-mongodb')
;
var storage = require('../storage');
module.exports = storage;

View File

@@ -3,7 +3,7 @@
expect = require('chai').expect
dpd = require('../')
root = {key: 'foo', secret: 'bar'}
server = dpd.use('http://localhost:3003')
server = dpd.use('http://localhost:3003').storage('mongodb://localhost/deployd-testing-db')
client = require('mdoq').use('http://localhost:3003').use(function (req, res, next) {
req.headers['x-dssh-key'] = root.key;
next();