Change request path from /v1 to /api/v1

This commit is contained in:
Alvaro Bautista 2011-07-04 17:28:39 +02:00
parent 2e3575339c
commit f0df331fb4
2 changed files with 17 additions and 17 deletions

View File

@ -18,16 +18,16 @@ var express= require('express')
// for private (read/write) queries:
// - `auth_token` {String} oAuth API token from CartoDB. In URL or request header.
//
// eg. /v1/?sql=SELECT 1 as one&auth_token=my_token
// eg. /api/v1/?sql=SELECT 1 as one&auth_token=my_token
//
// for public (read only) queries:
// - `database` {String} The database to execute queries on
//
// eg. /v1/?sql=SELECT 1 as one&database=my_public_db
// eg. /api/v1/?sql=SELECT 1 as one&database=my_public_db
//
// NOTE: private queries can only be ran on databases the oAuth key gives access to.
app.get('/v1/', function(req, res){
// NOTE: private queries can only be ran on databases the oAuth key gives access to.
app.get('/api/v1/', function(req, res){
//sanitize input
var sql = req.query.sql;
var database = req.query.database;

View File

@ -7,50 +7,50 @@ var app = require(global.settings.app_root + '/app/controllers/app')
, assert = require('assert');
module.exports = {
'GET /v1/': function(){
'GET /api/v1/': function(){
assert.response(app, {
url: '/v1/',
url: '/api/v1/',
method: 'GET'
},{
body: '{"error":["You must indicate a sql query"]}',
status: 400
});
},
'GET /v1/ with SQL parameter on SELECT only. No oAuth included ': function(){
'GET /api/v1/ with SQL parameter on SELECT only. No oAuth included ': function(){
assert.response(app, {
url: '/v1/?sql=SELECT%20*%20FROM%20test_table&database=cartodb_test_user_1_db',
url: '/api/v1/?sql=SELECT%20*%20FROM%20test_table&database=cartodb_test_user_1_db',
method: 'GET'
},{
status: 200
});
},
'GET /v1/ with SQL parameter on SELECT only. oAuth used ': function(){
'GET /api/v1/ with SQL parameter on SELECT only. oAuth used ': function(){
assert.response(app, {
url: '/v1/?sql=SELECT%20*%20FROM%20test_table&oauth_token=1',
url: '/api/v1/?sql=SELECT%20*%20FROM%20test_table&oauth_token=1',
method: 'GET'
},{
status: 200
});
},
'GET /v1/ with SQL parameter on INSERT only. oAuth used ': function(){
'GET /api/v1/ with SQL parameter on INSERT only. oAuth used ': function(){
assert.response(app, {
url: "/v1/?sql=INSERT%20INTO%20test_table%20(id)%20VALUES%20(1)&oauth_token=1",
url: "/api/v1/?sql=INSERT%20INTO%20test_table%20(id)%20VALUES%20(1)&oauth_token=1",
method: 'GET'
},{
status: 200
});
},
'GET /v1/ with SQL parameter on INSERT only. oAuth not used, so public user - should fail': function(){
'GET /api/v1/ with SQL parameter on INSERT only. oAuth not used, so public user - should fail': function(){
assert.response(app, {
url: "/v1/?sql=INSERT%20INTO%20test_table%20(id)%20VALUES%20(1)&database=cartodb_test_user_1_db",
url: "/api/v1/?sql=INSERT%20INTO%20test_table%20(id)%20VALUES%20(1)&database=cartodb_test_user_1_db",
method: 'GET'
},{
status: 400
});
},
'GET /v1/ with SQL parameter on DROP DATABASE nly. oAuth not used, so public user - should fail': function(){
'GET /api/v1/ with SQL parameter on DROP DATABASE nly. oAuth not used, so public user - should fail': function(){
assert.response(app, {
url: "/v1/?sql=DROP%20TABLE%20cartodb_test_user_1_db&database=cartodb_test_user_1_db",
url: "/api/v1/?sql=DROP%20TABLE%20cartodb_test_user_1_db&database=cartodb_test_user_1_db",
method: 'GET'
},{
status: 400