misc_pterodactyl-panel/resources/scripts/api/server/files/loadDirectory.ts

24 lines
592 B
TypeScript
Raw Normal View History

2019-07-28 03:23:51 +00:00
import http from '@/api/http';
import { rawDataToFileObject } from '@/api/transformers';
2019-07-28 03:23:51 +00:00
export interface FileObject {
uuid: string;
2019-07-28 03:23:51 +00:00
name: string;
mode: string;
size: number;
isFile: boolean;
isSymlink: boolean;
isEditable: boolean;
mimetype: string;
createdAt: Date;
modifiedAt: Date;
}
export default async (uuid: string, directory?: string): Promise<FileObject[]> => {
const { data } = await http.get(`/api/client/servers/${uuid}/files/list`, {
params: { directory },
2019-07-28 03:23:51 +00:00
});
return (data.data || []).map(rawDataToFileObject);
2019-07-28 03:23:51 +00:00
};