parent
e8c315fe98
commit
622846b453
1
NEWS.md
1
NEWS.md
@ -4,6 +4,7 @@
|
||||
New features:
|
||||
|
||||
* Add optional support for rollbar (#137)
|
||||
* Add '/version' endpoint (#138)
|
||||
|
||||
Enhancements:
|
||||
|
||||
|
@ -94,6 +94,13 @@ if ( global.settings.hasOwnProperty('node_socket_timeout') ) {
|
||||
});
|
||||
}
|
||||
|
||||
// Version extracting function
|
||||
function getVersion() {
|
||||
var version = {};
|
||||
version.cartodb_sql_api = require(__dirname + '/../../package.json').version;
|
||||
return version;
|
||||
}
|
||||
|
||||
app.use(express.bodyParser());
|
||||
app.enable('jsonp callback');
|
||||
app.set("trust proxy", true);
|
||||
@ -103,6 +110,9 @@ app.options('*', function(req,res) { setCrossDomain(res); res.end(); });
|
||||
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) } );
|
||||
app.get(global.settings.base_url+'/version', function(req, res) {
|
||||
res.send(getVersion());
|
||||
});
|
||||
|
||||
// Return true of the given query may write to the database
|
||||
//
|
||||
|
@ -33,6 +33,20 @@ var expected_cache_control = 'no-cache,max-age=31536000,must-revalidate,public';
|
||||
var expected_rw_cache_control = 'no-cache,max-age=0,must-revalidate,public';
|
||||
var expected_cache_control_persist = 'public,max-age=31536000';
|
||||
|
||||
test('GET /api/v1/version', function(done){
|
||||
assert.response(app, {
|
||||
url: '/api/v1/version',
|
||||
method: 'GET'
|
||||
},{}, function(res) {
|
||||
assert.equal(res.statusCode, 200);
|
||||
var parsed = JSON.parse(res.body);
|
||||
var sqlapi_version = require(__dirname + '/../../package.json').version;
|
||||
assert.ok(parsed.hasOwnProperty('cartodb_sql_api'), "No 'cartodb_sql_api' version in " + parsed);
|
||||
assert.equal(parsed.cartodb_sql_api, sqlapi_version);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('GET /api/v1/sql', function(done){
|
||||
assert.response(app, {
|
||||
url: '/api/v1/sql',
|
||||
|
Loading…
Reference in New Issue
Block a user