You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
521 B
14 lines
521 B
import { fullTextSearch } from "#server/service/search";
|
|
import { getContextUser } from "#server/utils/context";
|
|
|
|
export default defineWrappedResponseHandler({ auth: "required" }, async (event) => {
|
|
const user = getContextUser(event)!;
|
|
const query = getQuery(event);
|
|
const q = String(query.q || "").trim();
|
|
|
|
if (!q) return R.success([]);
|
|
|
|
const limit = Math.min(50, Math.max(1, parseInt(String(query.limit || "20"))));
|
|
const results = await fullTextSearch(q, user.id, limit);
|
|
return R.success(results);
|
|
});
|
|
|