From fd4bab78e1a21e710316088f9dd401b79cc3c32d Mon Sep 17 00:00:00 2001 From: "Andrew W. Hill" Date: Tue, 20 Sep 2011 18:04:26 -0700 Subject: [PATCH] moved sql.fogeojson? to sql?format=geojson --- app/controllers/app.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/controllers/app.js b/app/controllers/app.js index a027c37d..61c24763 100755 --- a/app/controllers/app.js +++ b/app/controllers/app.js @@ -26,11 +26,9 @@ var express= require('express') app.use(express.bodyParser()); app.enable('jsonp callback'); -app.get('/api/v1/sql', function(req, res) { handleQuery(req, res, null) } ); -app.post('/api/v1/sql', function(req, res) { handleQuery(req, res, null) } ); -app.get('/api/v1/sql.:f', function(req, res) { handleQuery(req, res, req.params.f) } ); -app.post('/api/v1/sql.:f', function(req, res) { handleQuery(req, res, req.params.f) } ); -function handleQuery(req, res, format){ +app.get('/api/v1/sql', function(req, res) { handleQuery(req, res) } ); +app.post('/api/v1/sql', function(req, res) { handleQuery(req, res) } ); +function handleQuery(req, res){ // sanitize input var body = (req.body) ? req.body : {}; @@ -38,7 +36,8 @@ function handleQuery(req, res, format){ var database = req.query.database; // deprecate this in future var limit = parseInt(req.query.rows_per_page); var offset = parseInt(req.query.page); - + var format = (req.query.format) ? req.query.format : null; + sql = (sql == "") ? null : sql; database = (database == "") ? null : database; limit = (_.isNumber(limit)) ? limit : null;