Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
searchKey,
engineName,
hostIdentifier,
beforeSearchCall = (queryOptions, next) => next(queryOptions),
beforeAutocompleteResultsCall = (queryOptions, next) => next(queryOptions),
beforeAutocompleteSuggestionsCall = (queryOptions, next) =>
next(queryOptions),
endpointBase = ""
}) {
if (!engineName || !(hostIdentifier || endpointBase) || !searchKey) {
throw Error(
"hostIdentifier or endpointBase, engineName, and searchKey are required"
);
}
this.client = ElasticAppSearch.createClient({
...(endpointBase && { endpointBase }), //Add property on condition
...(hostIdentifier && { hostIdentifier: hostIdentifier }),
apiKey: searchKey,
engineName: engineName,
additionalHeaders: {
"x-swiftype-integration": "search-ui",
"x-swiftype-integration-version": version
}
});
this.beforeSearchCall = beforeSearchCall;
this.beforeAutocompleteResultsCall = beforeAutocompleteResultsCall;
this.beforeAutocompleteSuggestionsCall = beforeAutocompleteSuggestionsCall;
}