Analytics v2 #45

Merged
bones7242 merged 3 commits from analytics-v2 into master 2017-06-30 01:14:29 +02:00
4 changed files with 13 additions and 14 deletions
Showing only changes of commit 6725345db3 - Show all commits

View file

@ -10,7 +10,7 @@ const { postToStats } = require('../helpers/libraries/statsHelpers.js');
module.exports = app => { module.exports = app => {
// route to run a claim_list request on the daemon // route to run a claim_list request on the daemon
app.get('/api/claim_list/:claim', ({ originalUrl, params, ip }, res) => { app.get('/api/claim_list/:claim', ({ originalUrl, params, ip }, res) => {
logger.debug(`GET request on ${originalUrl} from ${ip}`); logger.verbose(`GET request on ${originalUrl} from ${ip}`);
lbryApi lbryApi
.getClaimsList(params.claim) .getClaimsList(params.claim)
.then(claimsList => { .then(claimsList => {
@ -23,7 +23,7 @@ module.exports = app => {
}); });
// route to run a resolve request on the daemon // route to run a resolve request on the daemon
app.get('/api/resolve/:uri', ({ originalUrl, params, ip }, res) => { app.get('/api/resolve/:uri', ({ originalUrl, params, ip }, res) => {
logger.debug(`GET request on ${originalUrl} from ${ip}`); logger.verbose(`GET request on ${originalUrl} from ${ip}`);
lbryApi lbryApi
.resolveUri(params.uri) .resolveUri(params.uri)
.then(resolvedUri => { .then(resolvedUri => {
@ -36,7 +36,7 @@ module.exports = app => {
}); });
// route to run a publish request on the daemon // route to run a publish request on the daemon
app.post('/api/publish', multipartMiddleware, ({ originalUrl, body, files, ip }, res) => { app.post('/api/publish', multipartMiddleware, ({ originalUrl, body, files, ip }, res) => {
logger.debug(`POST request on ${originalUrl} from ${ip}`); logger.verbose(`POST request on ${originalUrl} from ${ip}`);
// validate that a file was provided // validate that a file was provided
const file = files.speech || files.null; const file = files.speech || files.null;
if (!file) { if (!file) {

View file

@ -5,7 +5,6 @@ module.exports = app => {
// route for the home page // route for the home page
app.get('/', ({ originalUrl, ip, headers }, res) => { app.get('/', ({ originalUrl, ip, headers }, res) => {
logger.verbose(`GET request on ${originalUrl} from ${ip}`); logger.verbose(`GET request on ${originalUrl} from ${ip}`);
logger.debug(`headers ${JSON.stringify(headers)}`);
res.status(200).render('index'); res.status(200).render('index');
}); });
// a catch-all route if someone visits a page that does not exist // a catch-all route if someone visits a page that does not exist

View file

@ -34,35 +34,31 @@ function serveFile ({ fileName, fileType, filePath }, res) {
module.exports = (app) => { module.exports = (app) => {
// route to fetch one free public claim // route to fetch one free public claim
app.get('/:name/:claim_id', ({ originalUrl, params, ip, ips, headers }, res) => { app.get('/:name/:claim_id', ({ originalUrl, params, ip }, res) => {
logger.verbose(`GET request on ${originalUrl} from ${ip}`); logger.verbose(`GET request on ${originalUrl} from ${ip}`);
logger.debug(`ips >> ${JSON.stringify(ips)}`);
logger.debug(`headers >> ${JSON.stringify(headers)}`);
// begin image-serve processes // begin image-serve processes
serveController serveController
.getClaimByClaimId(params.name, params.claim_id) .getClaimByClaimId(params.name, params.claim_id)
.then(fileInfo => { .then(fileInfo => {
postToStats('serve', originalUrl, ips, 'success'); postToStats('serve', originalUrl, ip, 'success');
serveFile(fileInfo, res); serveFile(fileInfo, res);
}) })
.catch(error => { .catch(error => {
errorHandlers.handleRequestError('serve', originalUrl, ips, error, res); errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
}); });
}); });
// route to fetch one free public claim // route to fetch one free public claim
app.get('/:name', ({ originalUrl, params, ip, ips, headers }, res) => { app.get('/:name', ({ originalUrl, params, ip }, res) => {
logger.verbose(`GET request on ${originalUrl} from ${ip}`); logger.verbose(`GET request on ${originalUrl} from ${ip}`);
logger.debug(`ips >> ${JSON.stringify(ips)}`);
logger.debug(`headers >> ${JSON.stringify(headers)}`);
// begin image-serve processes // begin image-serve processes
serveController serveController
.getClaimByName(params.name) .getClaimByName(params.name)
.then(fileInfo => { .then(fileInfo => {
postToStats('serve', originalUrl, ips, 'success'); postToStats('serve', originalUrl, ip, 'success');
serveFile(fileInfo, res); serveFile(fileInfo, res);
}) })
.catch(error => { .catch(error => {
errorHandlers.handleRequestError('serve', originalUrl, ips, error, res); errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
}); });
}); });
}; };

View file

@ -1,3 +1,4 @@
const logger = require('winston');
const errorHandlers = require('../helpers/libraries/errorHandlers.js'); const errorHandlers = require('../helpers/libraries/errorHandlers.js');
const showController = require('../controllers/showController.js'); const showController = require('../controllers/showController.js');
const { postToStats } = require('../helpers/libraries/statsHelpers.js'); const { postToStats } = require('../helpers/libraries/statsHelpers.js');
@ -6,6 +7,7 @@ const statsController = require('../controllers/statsController.js');
module.exports = (app) => { module.exports = (app) => {
// route to show the meme-fodder meme maker // route to show the meme-fodder meme maker
app.get('/meme-fodder/play', ({ originalUrl, ip }, res) => { app.get('/meme-fodder/play', ({ originalUrl, ip }, res) => {
logger.verbose(`POST request on ${originalUrl} from ${ip}`);
// get and serve the content // get and serve the content
showController showController
.getAllClaims('meme-fodder') .getAllClaims('meme-fodder')
@ -19,6 +21,7 @@ module.exports = (app) => {
}); });
// route to show statistics for spee.ch // route to show statistics for spee.ch
app.get('/stats', ({ originalUrl, ip }, res) => { app.get('/stats', ({ originalUrl, ip }, res) => {
logger.verbose(`POST request on ${originalUrl} from ${ip}`);
// get and serve the content // get and serve the content
statsController statsController
.getStatsSummary() .getStatsSummary()
@ -32,6 +35,7 @@ module.exports = (app) => {
}); });
// route to display all free public claims at a given name // route to display all free public claims at a given name
app.get('/:name/all', ({ originalUrl, params, ip }, res) => { app.get('/:name/all', ({ originalUrl, params, ip }, res) => {
logger.verbose(`POST request on ${originalUrl} from ${ip}`);
// get and serve the content // get and serve the content
showController showController
.getAllClaims(params.name) .getAllClaims(params.name)