import { Meilisearch } from "meilisearch";
import { createResilientHttpClient } from "@playlive/tiltify-search/http-client";
const client = new Meilisearch({
host: "https://site-search.tiltify.com",
apiKey: "...",
httpClient: createResilientHttpClient({
onRetry: ({ attempt, status, retryAfterMs, bodySample }) => {
logger.warn({ attempt, status, retryAfterMs, bodySample }, "tiltify search retry");
},
}),
});
Build a Meilisearch-compatible
httpClientthat adds retry/backoff, content-type guards, and structured errors on top of nativefetch.The returned function matches the
httpClientshape Meilisearch expects ((...args: Parameters<typeof fetch>) => Promise<unknown>) and returns the parsed JSON response body (orundefinedfor empty bodies) on success. On unrecoverable failure it throws TiltifySearchHttpError.