forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadDirectory.ts
More file actions
27 lines (24 loc) · 854 Bytes
/
loadDirectory.ts
File metadata and controls
27 lines (24 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import http from '@/api/http';
import { rawDataToFileObject } from '@/api/transformers';
export interface FileObject {
key: string;
name: string;
mode: string;
modeBits: string,
size: number;
isFile: boolean;
isSymlink: boolean;
mimetype: string;
createdAt: Date;
modifiedAt: Date;
isArchiveType: () => boolean;
isEditable: () => boolean;
}
export default async (uuid: string, directory?: string): Promise<FileObject[]> => {
const { data } = await http.get(`/api/client/servers/${uuid}/files/list`, {
// At this point the directory is still encoded so we need to decode it since axios
// will automatically re-encode this value before sending it along in the request.
params: { directory: directory ?? '/' },
});
return (data.data || []).map(rawDataToFileObject);
};