"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = fsRoutes;
const node_path_1 = __importDefault(require("node:path"));
async function fsRoutes(fastify) {
    fastify.get("/ls", async (req) => {
        const q = req.query;
        const showSystem = q.showSystem === "1" || q.showSystem === true || q.showSystem === "true";
        return fastify.core.fs.ls(q.path || "", { showSystem, detectProject: true, detectConcurrency: 8 });
    });
    fastify.post("/mkdir", async (req) => {
        const body = req.body;
        return fastify.core.fs.mkdir(body?.path || "", body?.name || "", {
            recursive: true,
        });
    });
    fastify.get("/path-exists", async (req) => {
        const q = req.query;
        const raw = String(q?.path ?? "").trim();
        if (!raw)
            return { exists: false };
        const p = node_path_1.default.resolve(raw);
        const exists = await fastify.core.fs.exists(p);
        return { exists };
    });
}
