* refactor: optimize page loading and data fetching * fix: resolve recurring production runtime errors * feat: add MCP company and customer updates * fix: handle year-end tax adjustments * feat: harden annual report compliance * fix: expand invoice logo and font support * fix: sanitize API route error responses * fix: sanitize user-facing error messages * feat: persist onboarding and tax assessment notices * fix: reduce cloud backup audit churn * feat: refine invoice editor layout * fix: show saved tax adjustments in INK2 * fix: complete annual report API mappings * docs: record operational safeguards and decisions * fix: harden annual report review findings * fix: adjust column span for description based on VAT registration * New css class name
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
import { ensureInitialized } from '@/lib/init'
|
|
import { withRouteContext } from '@/lib/api/with-route-context'
|
|
import { verifyIntegrity } from '@/lib/core/documents/document-service'
|
|
import { getErrorMessage as getUserErrorMessage } from '@/lib/errors/get-error-message'
|
|
|
|
ensureInitialized()
|
|
|
|
/**
|
|
* POST /api/documents/:id/verify
|
|
* Verify document integrity by re-computing SHA-256 and comparing
|
|
*/
|
|
export const POST = withRouteContext<{ params: Promise<{ id: string }> }>(
|
|
'document.verify',
|
|
async (_request, { supabase, companyId }, { params }) => {
|
|
const { id } = await params
|
|
|
|
try {
|
|
const result = await verifyIntegrity(supabase, companyId, id)
|
|
|
|
return NextResponse.json({ data: result })
|
|
} catch (error) {
|
|
console.error('[documents/verify/POST] Verification failed:', error)
|
|
return NextResponse.json(
|
|
{ error: error instanceof Error ? getUserErrorMessage(error) : 'Verification failed' },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
},
|
|
{ requireWrite: true }
|
|
)
|