-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21faadb
commit 7f49f25
Showing
6 changed files
with
60 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { getAppIdAndApiKey } from '../getAppIdAndApiKey'; | ||
import algoliasearchV4 from 'algoliasearch'; | ||
import algoliasearchV3 from 'algoliasearch-v3'; | ||
|
||
const APP_ID = 'myAppId'; | ||
const API_KEY = 'myApiKey'; | ||
|
||
describe('getAppIdAndApiKey', () => { | ||
it('gets appId and apiKey from searchClient@v4', () => { | ||
const searchClient = algoliasearchV4(APP_ID, API_KEY); | ||
const [appId, apiKey] = getAppIdAndApiKey(searchClient); | ||
expect(appId).toEqual(APP_ID); | ||
expect(apiKey).toEqual(API_KEY); | ||
}); | ||
|
||
it('gets appId and apiKey from searchClient@v3', () => { | ||
const searchClient = algoliasearchV3(APP_ID, API_KEY); | ||
const [appId, apiKey] = getAppIdAndApiKey(searchClient); | ||
expect(appId).toEqual(APP_ID); | ||
expect(apiKey).toEqual(API_KEY); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export function getAppIdAndApiKey(searchClient) { | ||
if (searchClient.transporter) { | ||
// searchClient v4 | ||
const { headers, queryParameters } = searchClient.transporter; | ||
const APP_ID = 'x-algolia-application-id'; | ||
const API_KEY = 'x-algolia-api-key'; | ||
const appId = headers[APP_ID] || queryParameters[APP_ID]; | ||
const apiKey = headers[API_KEY] || queryParameters[API_KEY]; | ||
return [appId, apiKey]; | ||
} else { | ||
// searchClient v3 | ||
return [searchClient.applicationID, searchClient.apiKey]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3573,6 +3573,27 @@ algoliasearch-helper@^3.2.2: | |
dependencies: | ||
events "^1.1.1" | ||
|
||
"algoliasearch-v3@npm:algoliasearch@3": | ||
version "3.35.1" | ||
resolved "https://registry.npmjs.org/algoliasearch/-/algoliasearch-3.35.1.tgz#297d15f534a3507cab2f5dfb996019cac7568f0c" | ||
integrity sha512-K4yKVhaHkXfJ/xcUnil04xiSrB8B8yHZoFEhWNpXg23eiCnqvTZw1tn/SqvdsANlYHLJlKl0qi3I/Q2Sqo7LwQ== | ||
dependencies: | ||
agentkeepalive "^2.2.0" | ||
debug "^2.6.9" | ||
envify "^4.0.0" | ||
es6-promise "^4.1.0" | ||
events "^1.1.0" | ||
foreach "^2.0.5" | ||
global "^4.3.2" | ||
inherits "^2.0.1" | ||
isarray "^2.0.1" | ||
load-script "^1.0.0" | ||
object-keys "^1.0.11" | ||
querystring-es3 "^0.2.1" | ||
reduce "^1.0.1" | ||
semver "^5.1.0" | ||
tunnel-agent "^0.6.0" | ||
|
||
[email protected]: | ||
version "4.3.1" | ||
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.3.1.tgz#dea6ad87705e0439855cf3e5a4406b74e794b874" | ||
|