spee.ch/routes/api-routes.js

28 lines
918 B
JavaScript
Raw Normal View History

var errorHandlers = require("../helpers/libraries/errorHandlers.js");
var lbryApi = require("../helpers/libraries/lbryApi.js");
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)
.then(function(claimsList){
2017-06-14 00:39:38 +02:00
console.log("/api/claim_list/:claim success.");
res.status(200).json(claimsList);
})
2017-06-14 00:39:38 +02:00
.catch(function(error){
console.log("/api/claim_list/:name error:", error);
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){
errorHandlers.handleRequestError(error, res);
2017-06-14 00:39:38 +02:00
});
});
}