|
|
|
@ -6,22 +6,23 @@ var request = require('request') |
|
|
|
|
module.exports = { |
|
|
|
|
handleGithubCall: function (root, path, cb) { |
|
|
|
|
return request.get( |
|
|
|
|
{ |
|
|
|
|
url: 'https://api.github.com/repos/' + root + '/contents/' + path, |
|
|
|
|
json: true, |
|
|
|
|
headers: { |
|
|
|
|
'User-Agent': 'Remix' |
|
|
|
|
} |
|
|
|
|
}, (err, r, data) => { |
|
|
|
|
if (err) { |
|
|
|
|
return cb(err || 'Unknown transport error') |
|
|
|
|
} |
|
|
|
|
if ('content' in data) { |
|
|
|
|
cb(null, base64.decode(data.content), root + '/' + path) |
|
|
|
|
} else { |
|
|
|
|
cb('Content not received') |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
{ |
|
|
|
|
url: 'https://api.github.com/repos/' + root + '/contents/' + path, |
|
|
|
|
json: true, |
|
|
|
|
headers: { |
|
|
|
|
'User-Agent': 'Remix' |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
(err, r, data) => { |
|
|
|
|
if (err) { |
|
|
|
|
return cb(err || 'Unknown transport error') |
|
|
|
|
} |
|
|
|
|
if ('content' in data) { |
|
|
|
|
cb(null, base64.decode(data.content), root + '/' + path) |
|
|
|
|
} else { |
|
|
|
|
cb('Content not received') |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
handleSwarmImport: function (url, cb) { |
|
|
|
@ -35,17 +36,18 @@ module.exports = { |
|
|
|
|
url = url.replace(/^ipfs:\/\/?/, 'ipfs/') |
|
|
|
|
|
|
|
|
|
return request.get( |
|
|
|
|
{ |
|
|
|
|
url: 'https://gateway.ipfs.io/' + url, |
|
|
|
|
headers: { |
|
|
|
|
'User-Agent': 'Remix' |
|
|
|
|
} |
|
|
|
|
}, (err, r, data) => { |
|
|
|
|
if (err) { |
|
|
|
|
return cb(err || 'Unknown transport error') |
|
|
|
|
} |
|
|
|
|
cb(null, data, url) |
|
|
|
|
}) |
|
|
|
|
{ |
|
|
|
|
url: 'https://gateway.ipfs.io/' + url, |
|
|
|
|
headers: { |
|
|
|
|
'User-Agent': 'Remix' |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
(err, r, data) => { |
|
|
|
|
if (err) { |
|
|
|
|
return cb(err || 'Unknown transport error') |
|
|
|
|
} |
|
|
|
|
cb(null, data, url) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
handlers: function () { |
|
|
|
|