Analytics v2 #45
4 changed files with 13 additions and 14 deletions
|
@ -10,7 +10,7 @@ const { postToStats } = require('../helpers/libraries/statsHelpers.js');
|
|||
module.exports = app => {
|
||||
// route to run a claim_list request on the daemon
|
||||
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
|
||||
.getClaimsList(params.claim)
|
||||
.then(claimsList => {
|
||||
|
@ -23,7 +23,7 @@ module.exports = app => {
|
|||
});
|
||||
// route to run a resolve request on the daemon
|
||||
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
|
||||
.resolveUri(params.uri)
|
||||
.then(resolvedUri => {
|
||||
|
@ -36,7 +36,7 @@ module.exports = app => {
|
|||
});
|
||||
// route to run a publish request on the daemon
|
||||
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
|
||||
const file = files.speech || files.null;
|
||||
if (!file) {
|
||||
|
|
|
@ -5,7 +5,6 @@ module.exports = app => {
|
|||
// route for the home page
|
||||
app.get('/', ({ originalUrl, ip, headers }, res) => {
|
||||
logger.verbose(`GET request on ${originalUrl} from ${ip}`);
|
||||
logger.debug(`headers ${JSON.stringify(headers)}`);
|
||||
res.status(200).render('index');
|
||||
});
|
||||
// a catch-all route if someone visits a page that does not exist
|
||||
|
|
|
@ -34,35 +34,31 @@ function serveFile ({ fileName, fileType, filePath }, res) {
|
|||
|
||||
module.exports = (app) => {
|
||||
// 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.debug(`ips >> ${JSON.stringify(ips)}`);
|
||||
logger.debug(`headers >> ${JSON.stringify(headers)}`);
|
||||
// begin image-serve processes
|
||||
serveController
|
||||
.getClaimByClaimId(params.name, params.claim_id)
|
||||
.then(fileInfo => {
|
||||
postToStats('serve', originalUrl, ips, 'success');
|
||||
postToStats('serve', originalUrl, ip, 'success');
|
||||
serveFile(fileInfo, res);
|
||||
})
|
||||
.catch(error => {
|
||||
errorHandlers.handleRequestError('serve', originalUrl, ips, error, res);
|
||||
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
|
||||
});
|
||||
});
|
||||
// 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.debug(`ips >> ${JSON.stringify(ips)}`);
|
||||
logger.debug(`headers >> ${JSON.stringify(headers)}`);
|
||||
// begin image-serve processes
|
||||
serveController
|
||||
.getClaimByName(params.name)
|
||||
.then(fileInfo => {
|
||||
postToStats('serve', originalUrl, ips, 'success');
|
||||
postToStats('serve', originalUrl, ip, 'success');
|
||||
serveFile(fileInfo, res);
|
||||
})
|
||||
.catch(error => {
|
||||
errorHandlers.handleRequestError('serve', originalUrl, ips, error, res);
|
||||
errorHandlers.handleRequestError('serve', originalUrl, ip, error, res);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
const logger = require('winston');
|
||||
const errorHandlers = require('../helpers/libraries/errorHandlers.js');
|
||||
const showController = require('../controllers/showController.js');
|
||||
const { postToStats } = require('../helpers/libraries/statsHelpers.js');
|
||||
|
@ -6,6 +7,7 @@ const statsController = require('../controllers/statsController.js');
|
|||
module.exports = (app) => {
|
||||
// route to show the meme-fodder meme maker
|
||||
app.get('/meme-fodder/play', ({ originalUrl, ip }, res) => {
|
||||
logger.verbose(`POST request on ${originalUrl} from ${ip}`);
|
||||
// get and serve the content
|
||||
showController
|
||||
.getAllClaims('meme-fodder')
|
||||
|
@ -19,6 +21,7 @@ module.exports = (app) => {
|
|||
});
|
||||
// route to show statistics for spee.ch
|
||||
app.get('/stats', ({ originalUrl, ip }, res) => {
|
||||
logger.verbose(`POST request on ${originalUrl} from ${ip}`);
|
||||
// get and serve the content
|
||||
statsController
|
||||
.getStatsSummary()
|
||||
|
@ -32,6 +35,7 @@ module.exports = (app) => {
|
|||
});
|
||||
// route to display all free public claims at a given name
|
||||
app.get('/:name/all', ({ originalUrl, params, ip }, res) => {
|
||||
logger.verbose(`POST request on ${originalUrl} from ${ip}`);
|
||||
// get and serve the content
|
||||
showController
|
||||
.getAllClaims(params.name)
|
||||
|
|
Loading…
Reference in a new issue