aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/api/util.js
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-06-07 20:54:26 +0200
committerHampusM <hampus@hampusmat.com>2021-06-07 20:54:26 +0200
commit86395bd219b770133cb80d4bda4efc9155a4eef8 (patch)
treec07461a5da2e7ae4e8e29d930b4fbb63d2f509d3 /packages/server/src/api/util.js
parent6a89b265146edf689b83e2f0bf2d3d6d70eb538a (diff)
Refactored the backend. It's written in typescript now.
Diffstat (limited to 'packages/server/src/api/util.js')
-rw-r--r--packages/server/src/api/util.js45
1 files changed, 0 insertions, 45 deletions
diff --git a/packages/server/src/api/util.js b/packages/server/src/api/util.js
deleted file mode 100644
index aa31296..0000000
--- a/packages/server/src/api/util.js
+++ /dev/null
@@ -1,45 +0,0 @@
-const fs = require("fs");
-const git = require("./git");
-
-function verifyRepoName(dirty, base_dir)
-{
- return new Promise((resolve) =>
- {
- const is_valid_repo_name = /^[a-zA-Z0-9\\.\-_]+$/.test(dirty);
- if(!is_valid_repo_name) {
- resolve("ERR_REPO_REGEX");
- }
-
- fs.readdir(base_dir, (err, dir_content) =>
- {
- if(err) {
- resolve("ERR_REPO_NOT_FOUND");
- }
-
- dir_content = dir_content.filter(repo => repo.endsWith(".git"));
- if(!dir_content.includes(dirty + ".git")) {
- resolve("ERR_REPO_NOT_FOUND");
- }
-
- resolve(true);
- });
- });
-}
-
-async function verifyCommitID(base_dir, repo, dirty)
-{
- if(!/^[a-fA-F0-9]+$/.test(dirty)) {
- return "ERR_COMMIT_REGEX";
- }
-
- const commit_exists = await git.doesCommitExist(base_dir, repo, dirty);
-
- if(!commit_exists) {
- return "ERR_COMMIT_NOT_FOUND";
- }
-
- return true;
-}
-
-module.exports.verifyRepoName = verifyRepoName;
-module.exports.verifyCommitID = verifyCommitID; \ No newline at end of file