Add Image OCR search, Note Version History & Shared Notebooks

This commit is contained in:
chrisf committed 2026-10-22 22:48:36 -06:00
1 parent 247b63691a
commit 969b6ef083
21 files changed
+2166 -100

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';
import { runOcrOnAttachment } from '@/lib/ocr';
export async function GET(
_req: NextRequest,
context: { params: Promise<{ id: string }> }
) {
try {
const { id } = await context.params;
const attachment = await prisma.attachment.findUnique({
where: { id },
select: { id: true, filename: true, mimeType: true, extractedText: true },
});
if (!attachment) {
return NextResponse.json({ error: 'Attachment not found' }, { status: 404 });
}
return NextResponse.json({
id: attachment.id,
filename: attachment.filename,
extractedText: attachment.extractedText,
});
} catch (err: unknown) {
return NextResponse.json(
{ error: err instanceof Error ? err.message : 'Failed to fetch OCR text' },
{ status: 500 }
);
}
}
export async function POST(
_req: NextRequest,
context: { params: Promise<{ id: string }> }
) {
try {
const { id } = await context.params;
const result = await runOcrOnAttachment(id);
return NextResponse.json(result);
} catch (err: unknown) {
return NextResponse.json(
{ error: err instanceof Error ? err.message : 'OCR execution failed' },
{ status: 500 }
);
}
}