feat: add workspace service and route for directory management
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user