forked from mirror/crumbs-original
- Shared notes-service.ts with userId-scoped queries for DRY - McpServer with tools: list/get/create/update/trash/restore/ archive/unarchive/delete notes, search, list tags, pin, reorder, upload image - Streamable HTTP endpoint at POST /api/mcp - Session management with GET/DELETE handlers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
18 lines
572 B
TypeScript
18 lines
572 B
TypeScript
import { json } from '@sveltejs/kit';
|
|
import type { RequestHandler } from './$types.js';
|
|
import { reorderNotes } from '$lib/server/notes-service.js';
|
|
import { getUserId } from '$lib/server/api-utils.js';
|
|
|
|
export const POST: RequestHandler = async ({ request, ...event }) => {
|
|
const userId = getUserId(event);
|
|
const body = await request.json();
|
|
const orders: { id: string; sortOrder: number }[] = body.orders;
|
|
|
|
if (!Array.isArray(orders)) {
|
|
return json({ error: 'Invalid payload' }, { status: 400 });
|
|
}
|
|
|
|
reorderNotes(userId, orders);
|
|
return json({ ok: true });
|
|
};
|