refactor: tighten upload and viewer contracts

This commit is contained in:
Tom Boullay
2026-05-13 17:50:26 +02:00
parent 30ff9826dc
commit f6ac71dad2
11 changed files with 108 additions and 86 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ export function uploadLockConflictResponse() {
return uploadErrorMessageResponse(UPLOAD_LOCK_ERROR, 409)
}
export function parseStagingRequestBody(value: unknown): StagingRequestBody {
function parseStagingRequestBody(value: unknown): StagingRequestBody {
if (!isRecord(value) || typeof value.stagingId !== 'string' || value.stagingId.trim() === '') {
throw new Error('stagingId manquant')
}
@@ -38,7 +38,7 @@ export async function readStagingRequestBody(req: Request): Promise<StagingReque
return parseStagingRequestBody(body)
}
export function parseDriveRequestBody(value: unknown): DriveRequestBody {
function parseDriveRequestBody(value: unknown): DriveRequestBody {
const { stagingId } = parseStagingRequestBody(value)
if (!isRecord(value) || (value.action !== 'new' && value.action !== 'replace')) {