algolia / algolia/algoliasearch-client-javascript
Ability to set callback that return fresh API Key
- Vorherrschende Sprache
- TypeScript
- Sterne
- 1.4k
- Forks
- 226
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
**Context :**
Following the issue #772, we can now check remaining validity of API Key.
**Problem :**
In our application, we are generating very short term API Keys (5 minutes) to always be compliant with filters and visibility that are set in the Key (from our backend according to user access rights).
It could be very cool to add a callback while creating the `searchclient` which will be called when API Key is near expiration and which should return a fresh API Key.
**Workaround :**
Currently, we are wrapping the search methods from `searchclient` into some of our wrappers that do the check before every request.
If we detect that API Key is expired, we generate a new `searchclient` with the updated API Key and use it to execute the query.
However there is two bad concerns about this workaround :
1. As searchclient instance change, the `InstantSearch` node seems to detect it and relaunch a new query (which is now duplicated).
2. As searchclient instance change, what happen to the currently built query cache ? Reset ?
Yours faithfully,
LCDP
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Keine Quelldatei oder kein Test ist genannt. Beginne damit, die Erstellung von searchclient und die Verwendung des API-Schlüssels nachzuverfolgen, und untersuche dann, wie InstantSearch Änderungen am Client beobachtet und seinen Query-Cache verwaltet. Als erledigt gilt, wenn das Timing des Callbacks und das Aktualisierungsverhalten vereinbart sind, ohne den Client zu ersetzen oder Abfragen zu duplizieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- api
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100