refactor: strengthen upload boundary types

This commit is contained in:
Tom Boullay
2026-04-27 17:21:44 +02:00
parent d049318a73
commit fd586f4185
7 changed files with 96 additions and 39 deletions
+6 -7
View File
@@ -8,6 +8,7 @@ import {
findNextVersion,
} from '@/lib/nextcloud'
import { acquireUploadLock, releaseUploadLock } from '@/lib/upload-lock'
import { parseDriveRequestBody } from '@/lib/upload-request'
export const runtime = 'nodejs'
export const dynamic = 'force-dynamic'
@@ -45,15 +46,13 @@ export async function POST(req: NextRequest) {
// --- Parse staging request ---
let folderName: string
let parsedFiles: Awaited<ReturnType<typeof readStagedOriginalFiles>>['files']
let action: string
let action: 'new' | 'replace'
try {
const body = await req.json()
const stagingId = body.stagingId
if (!stagingId || typeof stagingId !== 'string') {
throw new Error('stagingId manquant')
}
action = typeof body.action === 'string' ? body.action.trim() || 'new' : 'new'
const body: unknown = await req.json()
const parsedBody = parseDriveRequestBody(body)
action = parsedBody.action
const stagingId = parsedBody.stagingId
const staged = await readStagedOriginalFiles(stagingId)
folderName = staged.folderName
parsedFiles = staged.files