/** * @file Express router for /api/projects: every lane grouped by the git repo * it belongs to, with that repo's worktrees (see server/lib/projects.js). Read * on demand by the sidebar's project tree, never polled; `POST /refresh` drops * the cached roots and worktree lists first. * @author Nguyễn Ngọc Trí Vĩ */ const { Router } = require("express"); const lanesLib = require("../lib/lanes"); const { listProjects, clearProjectCaches } = require("../lib/projects"); const { sameOriginGuard } = require("../lib/same-origin"); const router = Router(); router.get("/", async (_req, res) => { res.json({ projects: await listProjects(lanesLib.listLanes()) }); }); router.post("/refresh", sameOriginGuard, async (_req, res) => { clearProjectCaches(); res.json({ projects: await listProjects(lanesLib.listLanes()) }); }); module.exports = router;