import { json } from "@lib/helpers.ts"; import { AccessDeniedError, BadRequestError } from "@lib/errors.ts"; import { parseResourceUrl, searchResource } from "@lib/search.ts"; import { define } from "../../../utils.ts"; export const handler = define.handlers({ async GET(ctx) { const req = ctx.req; const session = ctx.state.session; if (!session) { throw new AccessDeniedError(); } const s = parseResourceUrl(req.url); if (!s) { throw new BadRequestError(); } const resources = await searchResource(s); return json(resources); }, });