reorganized half of the helper functions

This commit is contained in:
bill bittner 2018-04-26 18:50:47 -07:00
parent e2c6670063
commit cfb7e47fbd
26 changed files with 46 additions and 37 deletions

View file

@ -1,6 +1,6 @@
const db = require('../models');
const logger = require('winston');
const { returnPaginatedChannelClaims } = require('../helpers/channelPagination.js');
const { returnPaginatedChannelClaims } = require('./utils/channelPagination.js');
const NO_CHANNEL = 'NO_CHANNEL';
const NO_CLAIM = 'NO_CLAIM';

View file

@ -1,10 +0,0 @@
module.exports = {
serializeSpeechUser (user, done) { // returns user data to be serialized into session
console.log('serializing user');
done(null, user);
},
deserializeSpeechUser (user, done) { // deserializes session and populates additional info to req.user
console.log('deserializing user');
done(null, user);
},
};

View file

@ -1,6 +1,6 @@
const { checkChannelAvailability } = require('../../controllers/publishController.js');
const { sendGATimingEvent } = require('../../helpers/googleAnalytics.js');
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
/*

View file

@ -1,5 +1,5 @@
const { getChannelClaims } = require('../../controllers/serveController.js');
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
const NO_CHANNEL = 'NO_CHANNEL';

View file

@ -1,5 +1,5 @@
const { getChannelData } = require('../../controllers/serveController.js');
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
const NO_CHANNEL = 'NO_CHANNEL';

View file

@ -1,4 +1,4 @@
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
const db = require('../../models');
/*

View file

@ -1,6 +1,6 @@
const { claimNameIsAvailable } = require('../../controllers/publishController.js');
const { sendGATimingEvent } = require('../../helpers/googleAnalytics.js');
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
/*

View file

@ -1,4 +1,4 @@
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
const db = require('../../models');
/*

View file

@ -1,6 +1,6 @@
const { getClaim } = require('../../helpers/lbryApi.js');
const { addGetResultsToFileData, createFileData } = require('../../helpers/publishHelpers.js');
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
const db = require('../../models');
/*

View file

@ -1,5 +1,5 @@
const { getClaimList } = require('../../helpers/lbryApi.js');
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
/*

View file

@ -1,5 +1,5 @@
const { getClaimId } = require('../../controllers/serveController.js');
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
const NO_CHANNEL = 'NO_CHANNEL';
const NO_CLAIM = 'NO_CLAIM';

View file

@ -2,7 +2,7 @@ const { createBasicPublishParams, createThumbnailPublishParams, parsePublishApiR
const { claimNameIsAvailable, publish } = require('../../controllers/publishController.js');
const { authenticateUser } = require('../../auth/authentication.js');
const { sendGATimingEvent } = require('../../helpers/googleAnalytics.js');
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
const { details: { host } } = require('../../../config/siteConfig.js');
/*

View file

@ -1,5 +1,5 @@
const { resolveUri } = require('../../helpers/lbryApi.js');
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
/*

View file

@ -1,4 +1,4 @@
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
const db = require('../../models');
/*

View file

@ -1,4 +1,4 @@
const { handleErrorResponse } = require('../../helpers/errorHandlers.js');
const { handleErrorResponse } = require('../utils/errorHandlers.js');
const db = require('../../models');
/*

View file

@ -1,6 +1,10 @@
const { sendGAServeEvent } = require('../../helpers/googleAnalytics');
const { determineResponseType, logRequestData, getClaimIdAndServeAsset } = require('../../helpers/serveHelpers.js');
const lbryUri = require('../../helpers/lbryUri.js');
const {
determineResponseType,
logRequestData,
getClaimIdAndServeAsset,
} = require('../utils/serve.js');
const lbryUri = require('../utils/lbryUri.js');
const handleShowRender = require('../../render/build/handleShowRender.js');
const SERVE = 'SERVE';

View file

@ -4,8 +4,8 @@ const {
flipClaimNameAndIdForBackwardsCompatibility,
logRequestData,
getClaimIdAndServeAsset,
} = require('../../helpers/serveHelpers.js');
const lbryUri = require('../../helpers/lbryUri.js');
} = require('../utils/serve.js');
const lbryUri = require('../utils/lbryUri.js');
const handleShowRender = require('../../render/build/handleShowRender.js');
const SERVE = 'SERVE';

View file

@ -1,5 +1,5 @@
const logger = require('winston');
const { getClaimId, getLocalFileRecord } = require('../controllers/serveController.js');
const { getClaimId, getLocalFileRecord } = require('../../controllers/serveController.js');
const { handleErrorResponse } = require('./errorHandlers.js');
const SERVE = 'SERVE';

View file

@ -1,10 +1,11 @@
const passport = require('passport');
const localLoginStrategy = require('./local-login.js');
const localSignupStrategy = require('./local-signup.js');
const { serializeSpeechUser, deserializeSpeechUser } = require('../helpers/authHelpers.js');
const localLoginStrategy = require('./utils/local-login.js');
const localSignupStrategy = require('./utils/local-signup.js');
const serializeUser = require('./utils/serializeUser.js');
const deserializeUser = require('./utils/deserializeUser.js');
passport.deserializeUser(deserializeSpeechUser);
passport.serializeUser(serializeSpeechUser);
passport.deserializeUser(deserializeUser);
passport.serializeUser(serializeUser);
passport.use('local-login', localLoginStrategy);
passport.use('local-signup', localSignupStrategy);

View file

@ -0,0 +1,7 @@
const deserializeUser = (user, done) => {
// deserializes session and populates additional info to req.user
console.log('deserializing user');
done(null, user);
};
module.exports = deserializeUser;

View file

@ -1,6 +1,6 @@
const PassportLocalStrategy = require('passport-local').Strategy;
const logger = require('winston');
const db = require('../models');
const db = require('../../models/index');
const returnUserAndChannelInfo = (userInstance) => {
return new Promise((resolve, reject) => {

View file

@ -1,7 +1,7 @@
const PassportLocalStrategy = require('passport-local').Strategy;
const lbryApi = require('../helpers/lbryApi.js');
const lbryApi = require('../../helpers/lbryApi.js');
const logger = require('winston');
const db = require('../models');
const db = require('../../models/index');
module.exports = new PassportLocalStrategy(
{

View file

@ -0,0 +1,7 @@
const serializeUser = (user, done) => {
// returns user data to be serialized into session
console.log('serializing user');
done(null, user);
};
module.exports = serializeUser;