From bb8444ebbc6b25f20c22770281a1198eb4cb3c51 Mon Sep 17 00:00:00 2001 From: seaHi Date: Tue, 22 Sep 2026 20:09:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E5=88=97=E8=A1=A8=E7=9A=84=20API=20=E8=B7=AF?= =?UTF-8?q?=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/api/v1/tags/+server.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/routes/api/v1/tags/+server.ts diff --git a/src/routes/api/v1/tags/+server.ts b/src/routes/api/v1/tags/+server.ts new file mode 100644 index 0000000..cdfe03b --- /dev/null +++ b/src/routes/api/v1/tags/+server.ts @@ -0,0 +1,18 @@ +import { json } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; + +export const GET: RequestHandler = async ({ platform }) => { + const db = platform?.env.DB; + if (!db) return json({ error: 'Database not connected' }, { status: 500 }); + + try { + const { results } = await db.prepare('SELECT id, name FROM tags ORDER BY name ASC').all(); + + return json({ + data: results + }); + } catch (err: unknown) { + console.error('Failed to get tags', err); + return json({ error: 'Failed to retrieve tags' }, { status: 500 }); + } +};