CartoDB-SQL-API/app/middlewares/handle-query.js

17 lines
423 B
JavaScript
Raw Normal View History

2019-02-26 21:36:11 +08:00
'use strict';
module.exports = function handleQuery(isBatchAPIQuery = false) {
return function handleQueryMiddleware(req, res, next) {
res.locals.sql = isBatchAPIQuery ? batchApiQuery(req) : notBatchApiQuery(req);
2019-02-26 21:36:11 +08:00
return next();
};
};
function notBatchApiQuery(req) {
return (req.body && req.body.q) || (req.query && req.query.q);
}
function batchApiQuery(req) {
return req.body.query;
}