feat: add search menu to all resources

This commit is contained in:
2023-08-06 00:33:06 +02:00
parent 32a7f89309
commit 0e0d26c939
12 changed files with 208 additions and 8 deletions

View File

@ -13,6 +13,12 @@ export const handler: Handlers = {
const query_by = url.searchParams.get("query_by") || "name,description";
let filter_by = "";
const type = url.searchParams.get("type");
if (type) {
filter_by = `type:=${type}`;
}
const typesenseClient = await getTypeSenseClient();
if (!typesenseClient) {
throw new Error("Query not available");
@ -23,7 +29,7 @@ export const handler: Handlers = {
.documents().search({
q: query,
query_by,
limit_hits: 100,
filter_by,
});
return json(searchResults.hits);