-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(javascript): add browser xhr requester (#115)
- Loading branch information
Showing
111 changed files
with
2,613 additions
and
1,707 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
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
2 changes: 0 additions & 2 deletions
2
clients/algoliasearch-client-javascript/client-abtesting/api.ts
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
clients/algoliasearch-client-javascript/client-abtesting/browser.ts
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,38 @@ | ||
import type { Host, Requester } from '@algolia/client-common'; | ||
import { XhrRequester } from '@algolia/requester-browser-xhr'; | ||
|
||
import { createAbtestingApi } from './src/abtestingApi'; | ||
import type { AbtestingApi, Region } from './src/abtestingApi'; | ||
|
||
export * from './src/abtestingApi'; | ||
export * from '@algolia/client-common'; | ||
|
||
export function abtestingApi( | ||
appId: string, | ||
apiKey: string, | ||
region?: Region, | ||
options?: { requester?: Requester; hosts?: Host[] } | ||
): AbtestingApi { | ||
if (!appId) { | ||
throw new Error('`appId` is missing.'); | ||
} | ||
|
||
if (!apiKey) { | ||
throw new Error('`apiKey` is missing.'); | ||
} | ||
|
||
return createAbtestingApi({ | ||
appId, | ||
apiKey, | ||
region, | ||
timeouts: { | ||
connect: 1, | ||
read: 2, | ||
write: 30, | ||
}, | ||
requester: options?.requester ?? new XhrRequester(), | ||
userAgents: [{ segment: 'Browser' }], | ||
authMode: 'WithinQueryParameters', | ||
...options, | ||
}); | ||
} |
37 changes: 37 additions & 0 deletions
37
clients/algoliasearch-client-javascript/client-abtesting/node.ts
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,37 @@ | ||
import type { Host, Requester } from '@algolia/client-common'; | ||
import { HttpRequester } from '@algolia/requester-node-http'; | ||
|
||
import { createAbtestingApi } from './src/abtestingApi'; | ||
import type { AbtestingApi, Region } from './src/abtestingApi'; | ||
|
||
export * from './src/abtestingApi'; | ||
export * from '@algolia/client-common'; | ||
|
||
export function abtestingApi( | ||
appId: string, | ||
apiKey: string, | ||
region?: Region, | ||
options?: { requester?: Requester; hosts?: Host[] } | ||
): AbtestingApi { | ||
if (!appId) { | ||
throw new Error('`appId` is missing.'); | ||
} | ||
|
||
if (!apiKey) { | ||
throw new Error('`apiKey` is missing.'); | ||
} | ||
|
||
return createAbtestingApi({ | ||
appId, | ||
apiKey, | ||
region, | ||
timeouts: { | ||
connect: 1, | ||
read: 2, | ||
write: 30, | ||
}, | ||
requester: options?.requester ?? new HttpRequester(), | ||
userAgents: [{ segment: 'Node.js', version: process.versions.node }], | ||
...options, | ||
}); | ||
} |
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
Oops, something went wrong.