2017-06-17 02:48:51 +02:00
|
|
|
var errorHandlers = require("../helpers/libraries/errorHandlers.js");
|
|
|
|
var lbryApi = require("../helpers/libraries/lbryApi.js");
|
2017-05-24 20:07:43 +02:00
|
|
|
|
2017-06-17 02:48:51 +02:00
|
|
|
module.exports = function(app){
|
2017-06-14 00:39:38 +02:00
|
|
|
// route to run a claim_list request on the daemon
|
|
|
|
app.get("/api/claim_list/:claim", function(req, res){
|
|
|
|
lbryApi.getClaimsList(req.params.claim)
|
2017-06-17 02:48:51 +02:00
|
|
|
.then(function(claimsList){
|
2017-06-14 00:39:38 +02:00
|
|
|
console.log("/api/claim_list/:claim success.");
|
2017-06-17 02:48:51 +02:00
|
|
|
res.status(200).json(claimsList);
|
2017-05-24 20:07:43 +02:00
|
|
|
})
|
2017-06-14 00:39:38 +02:00
|
|
|
.catch(function(error){
|
|
|
|
console.log("/api/claim_list/:name error:", error);
|
2017-06-17 02:48:51 +02:00
|
|
|
errorHandlers.handleRequestError(error, res);
|
2017-06-14 00:39:38 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
// route to run a resolve request on the daemon
|
|
|
|
app.get("/api/resolve/:uri", function(req, res){
|
|
|
|
lbryApi.resolveUri(req.params.uri)
|
|
|
|
.then(function(resolvedUri){
|
|
|
|
console.log("/api/resolve/:claim success.");
|
|
|
|
res.status(200).json(resolvedUri);
|
|
|
|
}).catch(function(error){
|
2017-06-17 02:48:51 +02:00
|
|
|
errorHandlers.handleRequestError(error, res);
|
2017-06-14 00:39:38 +02:00
|
|
|
});
|
2017-05-24 20:07:43 +02:00
|
|
|
});
|
2017-06-14 18:33:19 +02:00
|
|
|
|
2017-05-24 20:07:43 +02:00
|
|
|
}
|