mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-06-05 20:02:13 +08:00
Merge branch 'refactor/config' into 0.3
This commit is contained in:
15
README.md
15
README.md
@@ -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
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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
23
lib/storage.js
Normal 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;
|
||||
};
|
||||
@@ -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;
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user