fix: make search usable again
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { json } from "@lib/helpers.ts";
|
||||
import { AccessDeniedError } from "@lib/errors.ts";
|
||||
import { searchResource } from "@lib/search.ts";
|
||||
import { AccessDeniedError, BadRequestError } from "@lib/errors.ts";
|
||||
import { parseResourceUrl, searchResource } from "@lib/search.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET(req, ctx) {
|
||||
@@ -10,18 +10,13 @@ export const handler: Handlers = {
|
||||
throw new AccessDeniedError();
|
||||
}
|
||||
|
||||
const url = new URL(req.url);
|
||||
const s = parseResourceUrl(req.url);
|
||||
if (!s) {
|
||||
throw new BadRequestError();
|
||||
}
|
||||
|
||||
const types = url.searchParams.get("types")?.split(",");
|
||||
const tags = url.searchParams?.get("tags")?.split(",");
|
||||
const authors = url.searchParams?.get("authors")?.split(",");
|
||||
|
||||
const resources = await searchResource({
|
||||
q: url.searchParams.get("q") || "",
|
||||
types,
|
||||
tags,
|
||||
authors,
|
||||
});
|
||||
console.log(s);
|
||||
const resources = await searchResource(s);
|
||||
|
||||
return json(resources);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user