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

module.exports = (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 :("})
    }
};