aboutsummaryrefslogtreecommitdiff
path: root/api/routes/getPeers/index.js
blob: 47c075d5c66c45dace8919fd0c27807d267abdd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const config = require('../../config');
const fs = require('fs');

function getPeers(req, res)
{
    const path = config.peersFile;
    if(fs.existsSync(path)){
        res.writeHead(200, {'Content-Type': 'application/json'});
        res.end(JSON.stringify(JSON.parse(fs.readFileSync(path))));
    } else {
        res.writeHead(404, {'Content-Type': 'application/json'});
        res.end({"error":"No peers :("})
    }
};
module.exports = getPeers;