From e82d9498d836ea100a186c4d87a7d0314ec1693a Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 19 May 2021 15:59:12 +0200 Subject: Backend uses nodegit, gettings repos is a single function & backend cleaned up --- api/v1.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'api/v1.js') diff --git a/api/v1.js b/api/v1.js index 4987ba7..7920afc 100644 --- a/api/v1.js +++ b/api/v1.js @@ -12,15 +12,13 @@ router.get("/info", function(req, res) router.get("/repos", async function(req, res) { - let repo_dirs = await git.getRepos(req.settings["base_dir"]); + let repos = await git.getRepos(req.settings["base_dir"]); - if(repo_dirs["error"]) { + if(repos["error"]) { res.status(500).send("Internal server error!"); return; } - repo_dirs = repo_dirs["data"].filter(repo => repo.endsWith(".git")); - const repos = await git.getBasicRepoInfo(req.settings["base_dir"], repo_dirs); res.json({ "data": repos }); }); @@ -58,7 +56,7 @@ router.get("/repos/:repo/log", async function(req, res) } return; } - res.json(log); + res.json({ data: log }); }); router.get("/repos/:repo/log/:commit", async function(req, res) @@ -70,7 +68,7 @@ router.get("/repos/:repo/log/:commit", async function(req, res) const commit = await git.getCommit(req.settings["base_dir"], req.params.repo, req.params.commit); - res.json(commit); + res.json({ data: commit }); }); module.exports = router; \ No newline at end of file -- cgit v1.2.3-18-g5258