Remove the hardcoded lbry API address #325

Merged
maximest-pierre merged 1 commit from feature/remove_hardcoded_api_adress into master 2018-01-23 19:13:50 +01:00
2 changed files with 13 additions and 6 deletions

View file

@ -35,4 +35,8 @@ module.exports = {
testChannel : '@testpublishchannel', // a channel to make test publishes in
testChannelPassword: 'password', // password for the test channel
},
api: {
apiUri: 'localhost',
kauffj commented 2018-01-23 20:51:38 +01:00 (Migrated from github.com)
Review

If I'm being pedantic, which I am wont to do, this is more like a host than a URI. All of the parts together comprise the URI.

Here's a reference (this terminology is fairly universal, not google specific): https://www.mattcutts.com/blog/seo-glossary-url-definitions/

If I'm being pedantic, which I am wont to do, this is more like a host than a URI. All of the parts together comprise the URI. Here's a reference (this terminology is fairly universal, not google specific): https://www.mattcutts.com/blog/seo-glossary-url-definitions/
bones7242 commented 2018-01-23 21:35:58 +01:00 (Migrated from github.com)
Review

I'm wont to do it correctly

I'm wont to do it correctly
apiPort: '5279',
},
};

View file

@ -1,5 +1,8 @@
const axios = require('axios');
const logger = require('winston');
const config = require('../config/speechConfig.js');
const { apiUri, apiPort } = config.api;
const lbryApiUrl = 'http://' + apiUri + ':' + apiPort;
function handleLbrynetResponse ({ data }, resolve, reject) {
logger.debug('lbry api data:', data);
@ -22,7 +25,7 @@ module.exports = {
logger.debug(`lbryApi >> Publishing claim to "${publishParams.name}"`);
return new Promise((resolve, reject) => {
axios
.post('http://localhost:5279/lbryapi', {
.post(lbryApiUrl, {
method: 'publish',
params: publishParams,
})
@ -38,7 +41,7 @@ module.exports = {
logger.debug(`lbryApi >> Getting Claim for "${uri}"`);
return new Promise((resolve, reject) => {
axios
.post('http://localhost:5279/lbryapi', {
.post(lbryApiUrl, {
method: 'get',
params: { uri, timeout: 20 },
})
@ -54,7 +57,7 @@ module.exports = {
logger.debug(`lbryApi >> Getting claim_list for "${claimName}"`);
return new Promise((resolve, reject) => {
axios
.post('http://localhost:5279/lbryapi', {
.post(lbryApiUrl, {
method: 'claim_list',
params: { name: claimName },
})
@ -71,7 +74,7 @@ module.exports = {
// console.log('resolving uri', uri);
return new Promise((resolve, reject) => {
axios
.post('http://localhost:5279/lbryapi', {
.post(lbryApiUrl, {
method: 'resolve',
params: { uri },
})
@ -91,7 +94,7 @@ module.exports = {
logger.debug('lbryApi >> Retrieving the download directory path from lbry daemon...');
return new Promise((resolve, reject) => {
axios
.post('http://localhost:5279/lbryapi', {
.post(lbryApiUrl, {
method: 'settings_get',
})
.then(({ data }) => {
@ -110,7 +113,7 @@ module.exports = {
createChannel (name) {
return new Promise((resolve, reject) => {
axios
.post('http://localhost:5279/lbryapi', {
.post(lbryApiUrl, {
method: 'channel_new',
params: {
channel_name: name,