splitting behavior batch & not batch handling query
This commit is contained in:
parent
f925863534
commit
b618691af9
@ -43,7 +43,7 @@ JobController.prototype.route = function (app) {
|
||||
`${base_url}/sql/job`,
|
||||
bodyParserMiddleware(),
|
||||
checkBodyPayloadSize(),
|
||||
handleQueryMiddleware(),
|
||||
handleQueryMiddleware(true),
|
||||
jobMiddlewares('create', createJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_CREATE)
|
||||
);
|
||||
app.get(
|
||||
|
@ -1,8 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function handleQuery () {
|
||||
return function handleQueryMiddleware (req, res, next) {
|
||||
res.locals.sql = (req.body && (req.body.q || req.body.query)) || (req.query && req.query.q);
|
||||
module.exports = function handleQuery(isBatchAPIQuery = false) {
|
||||
return function handleQueryMiddleware(req, res, next) {
|
||||
res.locals.sql = isBatchAPIQuery ? batchApiQuery(req) : notBatchApiQuery(req);
|
||||
return next();
|
||||
};
|
||||
};
|
||||
|
||||
function notBatchApiQuery(req) {
|
||||
return (req.body && req.body.q) || (req.query && req.query.q);
|
||||
}
|
||||
|
||||
function batchApiQuery(req) {
|
||||
return req.body.query;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user