feat(karakeep): bookmark fetch client

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-01 03:54:21 +10:00
parent 62ac022f65
commit de1d7e3476
2 changed files with 46 additions and 0 deletions

11
lib/karakeep/client.js Normal file
View File

@@ -0,0 +1,11 @@
export async function getBookmark(id) {
const base = process.env.KARAKEEP_API_URL || 'https://karakeep.hynesy.com';
const tok = process.env.KARAKEEP_API_TOKEN || '';
const res = await fetch(`${base}/api/v1/bookmarks/${encodeURIComponent(id)}`, {
headers: { Authorization: 'Bearer ' + tok },
signal: AbortSignal.timeout(10_000)
});
if (res.status === 404) return null;
if (!res.ok) throw new Error(`karakeep ${res.status}`);
return res.json();
}