diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-06-10 18:02:33 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-06-10 18:02:33 +0300 |
commit | c581cd642440a5ac077f5073f6fbe3920b729ba7 (patch) | |
tree | f91f327f82287d9e4c20ff7ddd45350b36fcdc24 /api/routes/getPeers/index.js | |
parent | 40ad20464700357cbe50676abfb2cb24d33f5037 (diff) | |
download | arching-kaos-tools-c581cd642440a5ac077f5073f6fbe3920b729ba7.tar.gz arching-kaos-tools-c581cd642440a5ac077f5073f6fbe3920b729ba7.tar.bz2 arching-kaos-tools-c581cd642440a5ac077f5073f6fbe3920b729ba7.zip |
Refactoring
Diffstat (limited to 'api/routes/getPeers/index.js')
-rw-r--r-- | api/routes/getPeers/index.js | 6 |
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 :("}) } }; |