({
indexName,
query,
pageParam,
hitsPerPage = 10,
}: SearchOptions)
| 14 | } |
| 15 | |
| 16 | export async function search<TData>({ |
| 17 | indexName, |
| 18 | query, |
| 19 | pageParam, |
| 20 | hitsPerPage = 10, |
| 21 | }: SearchOptions): Promise<{ |
| 22 | hits: Array<Hit<TData>> |
| 23 | nextPage: number | undefined |
| 24 | }> { |
| 25 | const client = searchClient(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY) |
| 26 | |
| 27 | console.log('algolia:search', { indexName, query, pageParam, hitsPerPage }) |
| 28 | |
| 29 | const { hits, page, nbPages } = await client.searchSingleIndex<TData>({ |
| 30 | indexName, |
| 31 | searchParams: { query, page: pageParam, hitsPerPage }, |
| 32 | }) |
| 33 | |
| 34 | const nextPage = page + 1 < nbPages ? page + 1 : undefined |
| 35 | |
| 36 | return { hits, nextPage } |
| 37 | } |
no outgoing calls
no test coverage detected