Make base url configurable, use a wildcard in the example config

This commit is contained in:
Sandro Santilli 2013-05-23 11:49:23 +02:00
parent e5ad8f0760
commit 81a83b93e4
7 changed files with 23 additions and 3 deletions

View File

@ -1,6 +1,7 @@
1.3.10
------
* Fixed problem identifying OAuth request protocol
* Make base url configurable
1.3.9
-----

View File

@ -51,9 +51,9 @@ app.use(express.bodyParser());
app.enable('jsonp callback');
// basic routing
app.all('/api/v1/sql', function(req, res) { handleQuery(req, res) } );
app.all('/api/v1/sql.:f', function(req, res) { handleQuery(req, res) } );
app.get('/api/v1/cachestatus', function(req, res) { handleCacheStatus(req, res) } );
app.all(global.settings.base_url+'/sql', function(req, res) { handleQuery(req, res) } );
app.all(global.settings.base_url+'/sql.:f', function(req, res) { handleQuery(req, res) } );
app.get(global.settings.base_url+'/cachestatus', function(req, res) { handleCacheStatus(req, res) } );
// Return true of the given query may write to the database
//

View File

@ -1,3 +1,4 @@
module.exports.base_url = '/api/:version';
module.exports.node_port = 8080;
module.exports.node_host = '127.0.0.1';
// idle socket timeout, in miliseconds

View File

@ -1,3 +1,4 @@
module.exports.base_url = '/api/:version';
module.exports.node_port = 8080;
module.exports.node_host = '127.0.0.1';
// idle socket timeout, in miliseconds

View File

@ -1,3 +1,4 @@
module.exports.base_url = '/api/:version';
module.exports.node_port = 8080;
module.exports.node_host = '127.0.0.1';
// idle socket timeout, in miliseconds

View File

@ -1,3 +1,4 @@
module.exports.base_url = '/api/:version';
module.exports.node_port = 8080;
module.exports.node_host = '127.0.0.1';
// idle socket timeout, in miliseconds

View File

@ -56,6 +56,21 @@ test('GET /api/v1/sql', function(done){
});
});
// Test base_url setting
test('GET /api/whatever/sql', function(done){
assert.response(app, {
url: '/api/whatever/sql',
method: 'GET'
},{
status: 400
}, function(res) {
assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8');
assert.deepEqual(res.headers['content-disposition'], 'inline');
assert.deepEqual(JSON.parse(res.body), {"error":["You must indicate a sql query"]});
done();
});
});
test('GET /api/v1/sql with SQL parameter on SELECT only. No oAuth included ', function(done){
assert.response(app, {