2017-06-19 18:37:35 +02:00
|
|
|
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
|
|
|
const lbryApi = require('../helpers/libraries/lbryApi.js');
|
2017-06-19 22:10:06 +02:00
|
|
|
const logger = require('winston');
|
2017-05-24 20:07:43 +02:00
|
|
|
|
2017-06-17 22:51:30 +02:00
|
|
|
module.exports = app => {
|
|
|
|
// route to run a claim_list request on the daemon
|
2017-06-19 22:10:06 +02:00
|
|
|
app.get('/api/claim_list/:claim', ({ originalUrl, params }, res) => {
|
2017-06-20 04:34:34 +02:00
|
|
|
logger.debug(`GET request on ${originalUrl}`);
|
2017-06-17 22:51:30 +02:00
|
|
|
lbryApi
|
|
|
|
.getClaimsList(params.claim)
|
|
|
|
.then(claimsList => {
|
2017-06-19 18:37:35 +02:00
|
|
|
res.status(200).json(claimsList);
|
2017-06-17 22:51:30 +02:00
|
|
|
})
|
|
|
|
.catch(error => {
|
2017-06-19 18:37:35 +02:00
|
|
|
errorHandlers.handleRequestError(error, res);
|
|
|
|
});
|
|
|
|
});
|
2017-06-17 22:51:30 +02:00
|
|
|
// route to run a resolve request on the daemon
|
2017-06-19 22:10:06 +02:00
|
|
|
app.get('/api/resolve/:uri', ({ originalUrl, params }, res) => {
|
2017-06-20 04:34:34 +02:00
|
|
|
logger.debug(`GET request on ${originalUrl}`);
|
2017-06-17 22:51:30 +02:00
|
|
|
lbryApi
|
|
|
|
.resolveUri(params.uri)
|
|
|
|
.then(resolvedUri => {
|
2017-06-19 18:37:35 +02:00
|
|
|
res.status(200).json(resolvedUri);
|
2017-06-17 22:51:30 +02:00
|
|
|
})
|
|
|
|
.catch(error => {
|
2017-06-19 18:37:35 +02:00
|
|
|
errorHandlers.handleRequestError(error, res);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|