Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
transporter(requester: Requester, options: any = {}): Transporter {
const transporter = algoliasearch('appId', 'apiKey').transporter;
transporter.setHosts([
{ url: 'read.com', accept: CallEnum.Read },
{ url: 'write.com', accept: CallEnum.Write },
{ url: 'read-and-write.com', accept: CallEnum.Any },
]);
return Object.assign(transporter, {
requester,
hostsCache: createInMemoryCache(),
requestsCache: createNullCache(),
responsesCache: createNullCache(),
headers: {
'X-Default-Header': 'Default value',
},
queryParameters: {},
timeouts: {
read: 2,
write: 30,
connect: 1,
},
...options,
});
},
options: AlgoliaSearchOptions = {}
): SearchClient {
const logger = createConsoleLogger(options.logLevel || LogLevelEnum.Error);
return createSearchClient({
appId,
apiKey,
timeouts: {
connect: 1,
read: 2,
write: 30,
},
requester: createBrowserXhrRequester(),
logger,
responsesCache: createInMemoryCache(),
requestsCache: createInMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [
createBrowserLocalStorageCache({ key: `${version}-${appId}` }),
createInMemoryCache(),
],
}),
userAgent: createUserAgent(version).add({
segment: 'Browser',
version: 'lite',
}),
authMode: AuthMode.WithinQueryParameters,
methods: {
search: multipleQueries,
searchForFacetValues: multipleSearchForFacetValues,
multipleQueries,
multipleSearchForFacetValues,
options: AlgoliaSearchOptions = {}
): SearchClient {
const logger = createConsoleLogger(options.logLevel || LogLevelEnum.Error);
const clientOptions = {
appId,
apiKey,
timeouts: {
connect: 1,
read: 2,
write: 30,
},
requester: createBrowserXhrRequester(),
logger,
responsesCache: createInMemoryCache(),
requestsCache: createInMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [createBrowserLocalStorageCache({ version }), createInMemoryCache()],
}),
userAgent: createUserAgent(version).add({ segment: 'Browser' }),
};
return createSearchClient({
...clientOptions,
methods: {
search: multipleQueries,
searchForFacetValues: multipleSearchForFacetValues,
multipleBatch,
multipleGetObjects,
multipleQueries,
copyIndex,
copySettings,
return createSearchClient({
appId,
apiKey,
timeouts: {
connect: 1,
read: 2,
write: 30,
},
requester: createBrowserXhrRequester(),
logger,
responsesCache: createInMemoryCache(),
requestsCache: createInMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [
createBrowserLocalStorageCache({ key: `${version}-${appId}` }),
createInMemoryCache(),
],
}),
userAgent: createUserAgent(version).add({
segment: 'Browser',
version: 'lite',
}),
authMode: AuthMode.WithinQueryParameters,
methods: {
search: multipleQueries,
searchForFacetValues: multipleSearchForFacetValues,
multipleQueries,
multipleSearchForFacetValues,
initIndex: base => (indexName: string): SearchIndex => {
return initIndex(base)(indexName, {
methods: { search, searchForFacetValues },
});
apiKey: string,
options: AlgoliaSearchOptions = {}
): SearchClient {
const logger = createConsoleLogger(options.logLevel || LogLevelEnum.Error);
const clientOptions = {
appId,
apiKey,
timeouts: {
connect: 1,
read: 2,
write: 30,
},
requester: createBrowserXhrRequester(),
logger,
responsesCache: createInMemoryCache(),
requestsCache: createInMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [createBrowserLocalStorageCache({ version }), createInMemoryCache()],
}),
userAgent: createUserAgent(version).add({ segment: 'Browser' }),
};
return createSearchClient({
...clientOptions,
methods: {
search: multipleQueries,
searchForFacetValues: multipleSearchForFacetValues,
multipleBatch,
multipleGetObjects,
multipleQueries,
copyIndex,
apiKey: string,
options: AlgoliaSearchOptions = {}
): SearchClient {
const logger = createConsoleLogger(options.logLevel || LogLevelEnum.Error);
return createSearchClient({
appId,
apiKey,
timeouts: {
connect: 1,
read: 2,
write: 30,
},
requester: createBrowserXhrRequester(),
logger,
responsesCache: createInMemoryCache(),
requestsCache: createInMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [
createBrowserLocalStorageCache({ key: `${version}-${appId}` }),
createInMemoryCache(),
],
}),
userAgent: createUserAgent(version).add({
segment: 'Browser',
version: 'lite',
}),
authMode: AuthMode.WithinQueryParameters,
methods: {
search: multipleQueries,
searchForFacetValues: multipleSearchForFacetValues,
multipleQueries,
const logger = createConsoleLogger(options.logLevel || LogLevelEnum.Error);
const clientOptions = {
appId,
apiKey,
timeouts: {
connect: 1,
read: 2,
write: 30,
},
requester: createBrowserXhrRequester(),
logger,
responsesCache: createInMemoryCache(),
requestsCache: createInMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [createBrowserLocalStorageCache({ version }), createInMemoryCache()],
}),
userAgent: createUserAgent(version).add({ segment: 'Browser' }),
};
return createSearchClient({
...clientOptions,
methods: {
search: multipleQueries,
searchForFacetValues: multipleSearchForFacetValues,
multipleBatch,
multipleGetObjects,
multipleQueries,
copyIndex,
copySettings,
copySynonyms,
moveIndex,
export default function algoliasearch(appId: string, apiKey: string): SearchClient {
const clientOptions = {
appId,
apiKey,
timeouts: {
connect: 2,
read: 5,
write: 30,
},
requester: createNodeHttpRequester(),
logger: createNullLogger(),
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createInMemoryCache(),
userAgent: createUserAgent(version).add({
segment: 'Node.js',
version: process.versions.node,
}),
};
return createSearchClient({
...clientOptions,
methods: {
search: multipleQueries,
searchForFacetValues: multipleSearchForFacetValues,
multipleBatch,
multipleGetObjects,
multipleQueries,
copyIndex,
copySettings,