aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-06-10 18:02:33 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-06-10 18:02:33 +0300
commitc581cd642440a5ac077f5073f6fbe3920b729ba7 (patch)
treef91f327f82287d9e4c20ff7ddd45350b36fcdc24 /api
parent40ad20464700357cbe50676abfb2cb24d33f5037 (diff)
downloadarching-kaos-tools-c581cd642440a5ac077f5073f6fbe3920b729ba7.tar.gz
arching-kaos-tools-c581cd642440a5ac077f5073f6fbe3920b729ba7.tar.bz2
arching-kaos-tools-c581cd642440a5ac077f5073f6fbe3920b729ba7.zip
Refactoring
Diffstat (limited to 'api')
-rw-r--r--api/routes/getPeers/index.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/api/routes/getPeers/index.js b/api/routes/getPeers/index.js
index 22da56e..b18a015 100644
--- a/api/routes/getPeers/index.js
+++ b/api/routes/getPeers/index.js
@@ -4,8 +4,10 @@ const fs = require('fs');
module.exports = (req, res) => {
const path = config.peersFile;
if(fs.existsSync(path)){
- res.send(JSON.parse(fs.readFileSync(path)));
+ res.writeHead(200, {'Content-Type': 'application/json'});
+ res.end(JSON.stringify(JSON.parse(fs.readFileSync(path))));
} else {
- res.send({"error":"404"})
+ res.writeHead(404, {'Content-Type': 'application/json'});
+ res.end({"error":"No peers :("})
}
};