feat: use config for MultiSearchRoute

This commit is contained in:
Wieland Schöbl
2019-02-13 17:10:47 +01:00
committed by Rainer Killinger
parent 2b894bd1b6
commit 827827905b
6 changed files with 254 additions and 143 deletions

View File

@@ -14,6 +14,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {
SCConfigFile,
SCMultiSearchRequest,
SCMultiSearchResponse,
SCMultiSearchRoute,
@@ -32,11 +33,12 @@ export const multiSearchRouter = createRoute<SCMultiSearchResponse | SCTooManyRe
multiSearchRouteModel,
async (request: SCMultiSearchRequest, app) => {
const config: SCConfigFile = app.get('config');
const bulkMemory: BulkStorage = app.get('bulk');
const queryNames = Object.keys(request);
if (queryNames.length > 5) {
return new SCTooManyRequestsErrorResponse(app.get('isProductiveEnvironment'));
if (queryNames.length > config.backend.maxMultiSearchRouteQueries) {
throw new SCTooManyRequestsErrorResponse(app.get('isProductiveEnvironment'));
}
// get a map of promises for each query