File
Blob: src/worker/webdav/object.ts
| 1 | import { davError, emptyResponse } from "@/worker/dav/http"; |
| 2 | import { normalizeFilesPath } from "@/worker/dav/paths"; |
| 3 | import type { FileDavError, FileDavObject } from "@/worker/objects/file-dav-object"; |
| 4 | |
| 5 | export type NormalizedFilesRequestPath = ReturnType<typeof normalizeFilesPath> & { ok: true }; |
| 6 | |
| 7 | export function fileDavObject(env: Env, storageId: string): DurableObjectStub<FileDavObject> { |
| 8 | return env.FILE_DAV.getByName(storageId); |
| 9 | } |
| 10 | |
| 11 | export function resultError(result: FileDavError): Response { |
| 12 | if (result.status === 304) return emptyResponse(304); |
| 13 | return davError(result.status, result.message); |
| 14 | } |