feat: add workspace service and route for directory management

This commit is contained in:
plenarius
2026-04-20 18:26:51 -04:00
parent 421d591c1e
commit ee7a0783ea
3 changed files with 99 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import { Router } from "express";
import {
ensureWorkspaceStructure,
readConfig,
writeConfig,
getWorkspacePath,
} from "../services/workspace.service.js";
const router = Router();
router.get("/config", async (_req, res) => {
const config = await readConfig();
const sanitized = { ...config, githubPat: config.githubPat ? "***" : undefined };
res.json(sanitized);
});
router.put("/config", async (req, res) => {
const current = await readConfig();
const updated = { ...current, ...req.body };
await writeConfig(updated);
res.json({ ok: true });
});
router.post("/init", async (_req, res) => {
await ensureWorkspaceStructure();
res.json({ ok: true, path: getWorkspacePath() });
});
export default router;