Files
ra-h-os/app/api/quick-add/route.ts
T
“BeeRad” 1f8f41b4e0 feat: sync quick add ingestion updates
- simplify quick add source selection and fallback saving
- improve description context and manual edit behavior
- add extractor dimension filtering and edge explanation migration
2026-03-19 21:15:30 +11:00

38 lines
1.2 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { enqueueQuickAdd, QuickAddMode } from '@/services/agents/quickAdd';
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { input, mode, description } = body as { input?: unknown; mode?: unknown; description?: unknown };
if (typeof input !== 'string' || input.trim().length === 0) {
return NextResponse.json(
{ success: false, error: 'Input is required' },
{ status: 400 }
);
}
const normalizedMode: QuickAddMode | undefined =
mode === 'link' || mode === 'text' ? mode : undefined;
const normalizedDescription: string | undefined =
typeof description === 'string' && description.trim() ? description.trim() : undefined;
const result = await enqueueQuickAdd({
rawInput: input.trim(),
mode: normalizedMode,
description: normalizedDescription,
});
return NextResponse.json({ success: true, result });
} catch (error) {
console.error('[Quick Add API] Error:', error);
const message = error instanceof Error ? error.message : 'Unknown error';
return NextResponse.json(
{ success: false, error: message },
{ status: 500 }
);
}
}