mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
added format command and added trailing commas to reduce conflicts
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
||||
type BaseModuleApiOptions,
|
||||
ModuleApi,
|
||||
type PrimaryFieldType,
|
||||
type TInput
|
||||
type TInput,
|
||||
} from "modules/ModuleApi";
|
||||
import type { FileWithPath } from "ui/elements/media/file-selector";
|
||||
|
||||
@@ -12,7 +12,7 @@ export type MediaApiOptions = BaseModuleApiOptions & {};
|
||||
export class MediaApi extends ModuleApi<MediaApiOptions> {
|
||||
protected override getDefaultOptions(): Partial<MediaApiOptions> {
|
||||
return {
|
||||
basepath: "/api/media"
|
||||
basepath: "/api/media",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ export class MediaApi extends ModuleApi<MediaApiOptions> {
|
||||
getFile(filename: string) {
|
||||
return this.get<ReadableStream<Uint8Array>>(["file", filename], undefined, {
|
||||
headers: {
|
||||
Accept: "*/*"
|
||||
}
|
||||
Accept: "*/*",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ export class MediaApi extends ModuleApi<MediaApiOptions> {
|
||||
|
||||
getUploadHeaders(): Headers {
|
||||
return new Headers({
|
||||
Authorization: `Bearer ${this.options.token}`
|
||||
Authorization: `Bearer ${this.options.token}`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,11 +65,11 @@ export class MediaApi extends ModuleApi<MediaApiOptions> {
|
||||
filename?: string;
|
||||
path?: TInput;
|
||||
_init?: Omit<RequestInit, "body">;
|
||||
}
|
||||
},
|
||||
) {
|
||||
const headers = {
|
||||
"Content-Type": "application/octet-stream",
|
||||
...(opts?._init?.headers || {})
|
||||
...(opts?._init?.headers || {}),
|
||||
};
|
||||
let name: string = opts?.filename || "";
|
||||
try {
|
||||
@@ -87,7 +87,7 @@ export class MediaApi extends ModuleApi<MediaApiOptions> {
|
||||
|
||||
const init = {
|
||||
...(opts?._init || {}),
|
||||
headers
|
||||
headers,
|
||||
};
|
||||
if (opts?.path) {
|
||||
return this.post(opts.path, body, init);
|
||||
@@ -106,7 +106,7 @@ export class MediaApi extends ModuleApi<MediaApiOptions> {
|
||||
filename?: string;
|
||||
_init?: Omit<RequestInit, "body">;
|
||||
path?: TInput;
|
||||
} = {}
|
||||
} = {},
|
||||
) {
|
||||
if (item instanceof Request || typeof item === "string") {
|
||||
const res = await this.fetcher(item);
|
||||
@@ -124,9 +124,9 @@ export class MediaApi extends ModuleApi<MediaApiOptions> {
|
||||
...(opts._init ?? {}),
|
||||
headers: {
|
||||
...(opts._init?.headers ?? {}),
|
||||
"Content-Type": item.headers.get("Content-Type") || "application/octet-stream"
|
||||
}
|
||||
}
|
||||
"Content-Type": item.headers.get("Content-Type") || "application/octet-stream",
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -140,11 +140,11 @@ export class MediaApi extends ModuleApi<MediaApiOptions> {
|
||||
item: Request | Response | string | File | ReadableStream,
|
||||
opts?: {
|
||||
_init?: Omit<RequestInit, "body">;
|
||||
}
|
||||
},
|
||||
) {
|
||||
return this.upload(item, {
|
||||
...opts,
|
||||
path: ["entity", entity, id, field]
|
||||
path: ["entity", entity, id, field],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user