-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(javascript): remove classes usage (#156)
- Loading branch information
Showing
49 changed files
with
479 additions
and
341 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
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
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
7 changes: 3 additions & 4 deletions
7
clients/algoliasearch-client-javascript/packages/client-common/index.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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
export * from './src/createMemoryCache'; | ||
export * from './src/createAuth'; | ||
export * from './src/createEchoRequester'; | ||
export * from './src/createMemoryCache'; | ||
export * from './src/createStatefulHost'; | ||
export * from './src/createTransporter'; | ||
export * from './src/createUserAgent'; | ||
export * from './src/errors'; | ||
export * from './src/getUserAgent'; | ||
export * from './src/helpers'; | ||
export * from './src/Requester'; | ||
export * from './src/Response'; | ||
export * from './src/stackTrace'; | ||
export * from './src/StatefulHost'; | ||
export * from './src/Transporter'; | ||
export * from './src/types'; |
8 changes: 0 additions & 8 deletions
8
clients/algoliasearch-client-javascript/packages/client-common/src/Requester.ts
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
clients/algoliasearch-client-javascript/packages/client-common/src/StatefulHost.ts
This file was deleted.
Oops, something went wrong.
28 changes: 1 addition & 27 deletions
28
clients/algoliasearch-client-javascript/packages/client-common/src/createMemoryCache.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
22 changes: 22 additions & 0 deletions
22
clients/algoliasearch-client-javascript/packages/client-common/src/createStatefulHost.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,22 @@ | ||
import type { Host, StatefulHost } from './types'; | ||
|
||
// By default, API Clients at Algolia have expiration delay of 5 mins. | ||
// In the JavaScript client, we have 2 mins. | ||
const EXPIRATION_DELAY = 2 * 60 * 1000; | ||
|
||
export function createStatefulHost( | ||
host: Host, | ||
status: StatefulHost['status'] = 'up' | ||
): StatefulHost { | ||
const lastUpdate = Date.now(); | ||
|
||
function isUp(): boolean { | ||
return status === 'up' || Date.now() - lastUpdate > EXPIRATION_DELAY; | ||
} | ||
|
||
function isTimedout(): boolean { | ||
return status === 'timedout' && Date.now() - lastUpdate <= EXPIRATION_DELAY; | ||
} | ||
|
||
return { ...host, status, lastUpdate, isUp, isTimedout }; | ||
} |
Oops, something went wrong.