aboutsummaryrefslogtreecommitdiff
path: root/api/v1.js
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-04-17 22:45:12 +0200
committerHampusM <hampus@hampusmat.com>2021-04-17 22:45:12 +0200
commit15992970bc9d3eec402f6d85e40236e3095f0fc0 (patch)
treedd4bc2672d468b7ec74b41d089dae3b4ea4ed9f2 /api/v1.js
parent7ec5335b7893bd35fa2fa345e5c88ee5dbd5a656 (diff)
Finished repos api endpoint, created complete repos page & removed dist dir
Diffstat (limited to 'api/v1.js')
-rw-r--r--api/v1.js32
1 files changed, 6 insertions, 26 deletions
diff --git a/api/v1.js b/api/v1.js
index 6b96e94..75509ad 100644
--- a/api/v1.js
+++ b/api/v1.js
@@ -8,40 +8,20 @@ const base_dir="/home/hampus/Projects/"
router.get("/repos", async function(req, res)
{
- fs.readdir(base_dir, (err, files) =>
+ fs.readdir(base_dir, async (err, repo_dirs) =>
{
if(err) {
throw err;
}
+ repo_dirs = repo_dirs.filter(repo => repo.endsWith(".git"));
- var repos = {};
+ console.log("Repo dirs: " + repo_dirs);
- files = files.filter(repo => repo.endsWith(".git"));
+ const repos = await git.getBasicRepoInfo(base_dir, repo_dirs);
- let getRepoInfo = new Promise((resolve) =>
- {
- files.forEach((repo, index, arr) =>
- {
- fs.readFile(`${base_dir}/${repo}/description`, (err, content) =>
- {
- let desc = "";
-
- if(!err) {
- desc = content.toString();
- }
+ console.log("I v1.js\n" + JSON.stringify(repos) + "\n");
- repos[repo.slice(0, -4)] = { "description": desc };
-
- if(index === arr.length -1) resolve();
- })
- });
- });
-
- getRepoInfo.then(() =>
- {
- console.log(`Sist: ${JSON.stringify(repos)}`);
- res.json({ "data": repos });
- })
+ res.json({ "data": repos });
});
});