Separated pay, claim, and change wallet addresses #44
4 changed files with 21 additions and 13 deletions
|
@ -4,9 +4,15 @@ const logger = require('winston');
|
|||
module.exports = {
|
||||
postToAnalytics: (action, url, ipAddress, result) => {
|
||||
logger.silly('creating record for analytics');
|
||||
// make sure the result is a string
|
||||
if (result && (typeof result !== 'string')) {
|
||||
result = result.toString();
|
||||
}
|
||||
// // make sure the ip address(es) are a string
|
||||
if (ipAddress && (typeof ipAddress !== 'string')) {
|
||||
ipAddress = ipAddress.toString();
|
||||
}
|
||||
// create record in the db
|
||||
db.Analytics.create({
|
||||
action,
|
||||
url,
|
||||
|
|
|
@ -7,7 +7,7 @@ module.exports = {
|
|||
logger.debug(`Creating Publish Parameters for "${name}"`);
|
||||
// const payAddress = config.get('WalletConfig.LbryPayAddress');
|
||||
const claimAddress = config.get('WalletConfig.LbryClaimAddress');
|
||||
const changeAddress = config.get('WalletConfig.LbryChangeAddress');
|
||||
// const changeAddress = config.get('WalletConfig.LbryChangeAddress');
|
||||
// ensure nsfw is a boolean
|
||||
if (nsfw === false) {
|
||||
nsfw = false;
|
||||
|
@ -34,8 +34,8 @@ module.exports = {
|
|||
license,
|
||||
nsfw,
|
||||
},
|
||||
claim_address : claimAddress,
|
||||
change_address: changeAddress,
|
||||
claim_address: claimAddress,
|
||||
//change_address: changeAddress,
|
||||
};
|
||||
logger.debug('publishParams:', publishParams);
|
||||
return publishParams;
|
||||
|
|
|
@ -34,31 +34,33 @@ function serveFile ({ fileName, fileType, filePath }, res) {
|
|||
|
||||
module.exports = (app) => {
|
||||
// route to fetch one free public claim
|
||||
app.get('/:name/:claim_id', ({ originalUrl, params, ip }, res) => {
|
||||
logger.debug(`GET request on ${originalUrl} from ${ip}`);
|
||||
app.get('/:name/:claim_id', ({ originalUrl, params, ips, headers }, res) => {
|
||||
logger.debug(`GET request on ${originalUrl} from ${ips}`);
|
||||
logger.debug(`headers ${headers}`);
|
||||
// begin image-serve processes
|
||||
serveController
|
||||
.getClaimByClaimId(params.name, params.claim_id)
|
||||
.then(fileInfo => {
|
||||
postToAnalytics('serve', originalUrl, ip, 'success');
|
||||
postToAnalytics('serve', originalUrl, ips, 'success');
|
||||
serveFile(fileInfo, res);
|
||||
})
|
||||
.catch(error => {
|
||||
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
|
||||
errorHandlers.handleRequestError('serve', originalUrl, ips, error, res);
|
||||
});
|
||||
});
|
||||
// route to fetch one free public claim
|
||||
app.get('/:name', ({ originalUrl, params, ip }, res) => {
|
||||
logger.debug(`GET request on ${originalUrl} from ${ip}`);
|
||||
app.get('/:name', ({ originalUrl, params, ips, headers }, res) => {
|
||||
logger.debug(`GET request on ${originalUrl} from ${ips}`);
|
||||
logger.debug(`headers ${headers}`);
|
||||
// begin image-serve processes
|
||||
serveController
|
||||
.getClaimByName(params.name)
|
||||
.then(fileInfo => {
|
||||
postToAnalytics('serve', originalUrl, ip, 'success');
|
||||
postToAnalytics('serve', originalUrl, ips, 'success');
|
||||
serveFile(fileInfo, res);
|
||||
})
|
||||
.catch(error => {
|
||||
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
|
||||
errorHandlers.handleRequestError('serve', originalUrl, ips, error, res);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -16,12 +16,12 @@ require('./config/loggerSetup.js')(winston, logLevel, logDir);
|
|||
|
||||
// set port
|
||||
const PORT = 3000;
|
||||
// initialize express app
|
||||
// create an Express application
|
||||
const app = express();
|
||||
// require our models for syncing
|
||||
const db = require('./models');
|
||||
|
||||
// make express look in the public directory for assets (css/js/img)
|
||||
// serve static files from public directory (css/js/img)
|
||||
app.use(express.static(`${__dirname}/public`));
|
||||
|
||||
// configure express app
|
||||
|
|
Loading…
Add table
Reference in a new issue