Skip to content
File

Blob: src/worker/webdav/object.ts

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