Development #287
7 changed files with 10 additions and 19 deletions
|
@ -1,5 +1,4 @@
|
|||
const logger = require('winston');
|
||||
// const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js');
|
||||
|
||||
module.exports = {
|
||||
REGEXP_INVALID_CLAIM : /[^A-Za-z0-9-]/g,
|
|
@ -1,5 +1,4 @@
|
|||
const logger = require('winston');
|
||||
// const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js');
|
||||
|
||||
module.exports = {
|
||||
serveFile ({ filePath, fileType }, claimId, name, res) {
|
||||
|
|
|
@ -7,7 +7,6 @@ const { publish } = require('../controllers/publishController.js');
|
|||
const { getClaimList, resolveUri, getClaim } = require('../helpers/lbryApi.js');
|
||||
const { createPublishParams, validateApiPublishRequest, validatePublishSubmission, cleanseChannelName, checkClaimNameAvailability, checkChannelAvailability } = require('../helpers/publishHelpers.js');
|
||||
const errorHandlers = require('../helpers/errorHandlers.js');
|
||||
const { postToStats } = require('../controllers/statsController.js');
|
||||
const { authenticateOrSkip } = require('../auth/authentication.js');
|
||||
|
||||
function addGetResultsToFileData (fileInfo, getResult) {
|
||||
|
@ -35,7 +34,6 @@ module.exports = (app) => {
|
|||
app.get('/api/claim-list/:name', ({ ip, originalUrl, params }, res) => {
|
||||
getClaimList(params.name)
|
||||
.then(claimsList => {
|
||||
postToStats('serve', originalUrl, ip, null, null, 'success');
|
||||
res.status(200).json(claimsList);
|
||||
})
|
||||
.catch(error => {
|
||||
|
@ -119,7 +117,6 @@ module.exports = (app) => {
|
|||
app.get('/api/claim-resolve/:uri', ({ headers, ip, originalUrl, params }, res) => {
|
||||
resolveUri(params.uri)
|
||||
.then(resolvedUri => {
|
||||
postToStats('serve', originalUrl, ip, null, null, 'success');
|
||||
res.status(200).json(resolvedUri);
|
||||
})
|
||||
.catch(error => {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const { postToStats } = require('../controllers/statsController.js');
|
||||
|
||||
module.exports = app => {
|
||||
// route for the home page
|
||||
app.get('/', (req, res) => {
|
||||
|
@ -7,8 +5,6 @@ module.exports = app => {
|
|||
});
|
||||
// a catch-all route if someone visits a page that does not exist
|
||||
app.use('*', ({ originalUrl, ip }, res) => {
|
||||
// post to stats
|
||||
postToStats('show', originalUrl, ip, null, null, 'Error: 404');
|
||||
// send response
|
||||
res.status(404).render('fourOhFour');
|
||||
});
|
||||
|
|
|
@ -43,7 +43,6 @@ module.exports = (app) => {
|
|||
app.get('/new', ({ ip, originalUrl }, res) => {
|
||||
getRecentClaims()
|
||||
.then(result => {
|
||||
// logger.debug(result);
|
||||
res.status(200).render('new', { newClaims: result });
|
||||
})
|
||||
.catch(error => {
|
||||
|
|
|
@ -2,8 +2,9 @@ const logger = require('winston');
|
|||
const { getClaimId, getChannelInfoAndClaims, getLocalFileRecord } = require('../controllers/serveController.js');
|
||||
const serveHelpers = require('../helpers/serveHelpers.js');
|
||||
const { handleRequestError } = require('../helpers/errorHandlers.js');
|
||||
const { postToStats } = require('../controllers/statsController.js');
|
||||
const db = require('../models');
|
||||
const lbryuri = require('../helpers/lbryuri.js');
|
||||
const lbryUri = require('../helpers/lbryUri.js');
|
||||
|
||||
const SERVE = 'SERVE';
|
||||
const SHOW = 'SHOW';
|
||||
|
@ -171,10 +172,9 @@ function serveAssetToClient (claimId, name, res) {
|
|||
.then(fileInfo => {
|
||||
logger.debug('fileInfo:', fileInfo);
|
||||
if (fileInfo === NO_FILE) {
|
||||
res.status(307).redirect(`/api/claim-get/${name}/${claimId}`);
|
||||
} else {
|
||||
return serveHelpers.serveFile(fileInfo, claimId, name, res);
|
||||
return res.status(307).redirect(`/api/claim-get/${name}/${claimId}`);
|
||||
}
|
||||
return serveHelpers.serveFile(fileInfo, claimId, name, res);
|
||||
})
|
||||
.catch(error => {
|
||||
throw error;
|
||||
|
@ -216,8 +216,8 @@ module.exports = (app) => {
|
|||
app.get('/:identifier/:name', ({ headers, ip, originalUrl, params }, res) => {
|
||||
let isChannel, channelName, channelClaimId, claimId, claimName, isServeRequest;
|
||||
try {
|
||||
({ isChannel, channelName, channelClaimId, claimId } = lbryuri.parseIdentifier(params.identifier));
|
||||
({ claimName, isServeRequest } = lbryuri.parseName(params.name));
|
||||
({ isChannel, channelName, channelClaimId, claimId } = lbryUri.parseIdentifier(params.identifier));
|
||||
({ claimName, isServeRequest } = lbryUri.parseName(params.name));
|
||||
} catch (error) {
|
||||
return handleRequestError(originalUrl, ip, error, res);
|
||||
}
|
||||
|
@ -236,6 +236,7 @@ module.exports = (app) => {
|
|||
return res.status(200).render('noChannel');
|
||||
}
|
||||
showOrServeAsset(responseType, fullClaimId, claimName, res);
|
||||
postToStats(responseType, originalUrl, ip, claimName, fullClaimId, 'success');
|
||||
})
|
||||
.catch(error => {
|
||||
handleRequestError(originalUrl, ip, error, res);
|
||||
|
@ -245,7 +246,7 @@ module.exports = (app) => {
|
|||
app.get('/:identifier', ({ headers, ip, originalUrl, params, query }, res) => {
|
||||
let isChannel, channelName, channelClaimId;
|
||||
try {
|
||||
({ isChannel, channelName, channelClaimId } = lbryuri.parseIdentifier(params.identifier));
|
||||
({ isChannel, channelName, channelClaimId } = lbryUri.parseIdentifier(params.identifier));
|
||||
} catch (error) {
|
||||
return handleRequestError(originalUrl, ip, error, res);
|
||||
}
|
||||
|
@ -257,7 +258,7 @@ module.exports = (app) => {
|
|||
} else {
|
||||
let claimName, isServeRequest;
|
||||
try {
|
||||
({claimName, isServeRequest} = lbryuri.parseName(params.identifier));
|
||||
({claimName, isServeRequest} = lbryUri.parseName(params.identifier));
|
||||
} catch (error) {
|
||||
return handleRequestError(originalUrl, ip, error, res);
|
||||
}
|
||||
|
@ -271,6 +272,7 @@ module.exports = (app) => {
|
|||
return res.status(200).render('noClaim');
|
||||
}
|
||||
showOrServeAsset(responseType, fullClaimId, claimName, res);
|
||||
postToStats(responseType, originalUrl, ip, claimName, fullClaimId, 'success');
|
||||
})
|
||||
.catch(error => {
|
||||
handleRequestError(originalUrl, ip, error, res);
|
||||
|
|
|
@ -8,5 +8,4 @@
|
|||
<div class="hidden" onclick="window.location='{{this.claimId}}/{{this.name}}'">
|
||||
<p class="grid-item-details-text">{{this.name}}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue