2023-12-18 03:55:27 -07:00
|
|
|
import { listServerFiles } from "../k8s/server-files.js";
|
|
|
|
import { sendError } from "../util/ExpressClientError.js";
|
|
|
|
|
|
|
|
export async function listFiles(req, res) {
|
|
|
|
const serverSpec = req.body;
|
|
|
|
if (!serverSpec) return res.sendStatus(400);
|
|
|
|
if (!serverSpec.name) return res.status(400).send("Server name required!");
|
|
|
|
listServerFiles(serverSpec)
|
2023-12-18 16:50:33 -07:00
|
|
|
.then((f) => {
|
|
|
|
const fileData = f.map((fi, i) => ({
|
|
|
|
name: fi.name,
|
|
|
|
isDir: fi.type === 2,
|
|
|
|
id: `${fi.name}-${i}`,
|
|
|
|
isHidden: fi.name.startsWith("."),
|
|
|
|
isSymLink: !!fi.link,
|
|
|
|
size: fi.size,
|
|
|
|
}));
|
|
|
|
console.log(fileData);
|
|
|
|
res.json(fileData);
|
|
|
|
})
|
2023-12-18 03:55:27 -07:00
|
|
|
.catch(sendError(res));
|
|
|
|
}
|
2023-12-18 16:50:33 -07:00
|
|
|
|
|
|
|
export async function uploadFile(req, res) {}
|