feat: 新增搜素 API
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -22,6 +22,9 @@
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
/.idea/
|
||||
AGENTS.md
|
||||
CLAUDE.md
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
|
||||
12
app/api/resources/route.ts
Normal file
12
app/api/resources/route.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { resourceSearch } from "../../../lib/mcp-operations";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const searchParams = new URL(request.url).searchParams;
|
||||
return Response.json(
|
||||
await resourceSearch({
|
||||
query: searchParams.get("q") ?? "",
|
||||
limit: Number(searchParams.get("limit")) || 50,
|
||||
offset: Number(searchParams.get("offset")) || 0,
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -362,7 +362,7 @@ function resourceWhere(input: ResourceFilters) {
|
||||
const bindings: unknown[] = [];
|
||||
if (input.query?.trim()) {
|
||||
conditions.push(
|
||||
"(a.nickname LIKE ? ESCAPE '\\' OR a.public_account_id LIKE ? ESCAPE '\\' OR a.current_contact LIKE ? ESCAPE '\\' OR a.tags LIKE ? ESCAPE '\\' OR a.bio LIKE ? ESCAPE '\\')",
|
||||
"(a.nickname LIKE ? ESCAPE '\\\\' OR a.public_account_id LIKE ? ESCAPE '\\\\' OR a.current_contact LIKE ? ESCAPE '\\\\' OR a.tags LIKE ? ESCAPE '\\\\' OR a.bio LIKE ? ESCAPE '\\\\')",
|
||||
);
|
||||
const pattern = like(input.query.trim());
|
||||
bindings.push(pattern, pattern, pattern, pattern, pattern);
|
||||
|
||||
Reference in New Issue
Block a user