diff --git a/server/controllers/serveController.js b/server/controllers/serveController.js index a1a8fbc8..0513073a 100644 --- a/server/controllers/serveController.js +++ b/server/controllers/serveController.js @@ -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'; diff --git a/server/helpers/channelPagination.js b/server/controllers/utils/channelPagination.js similarity index 100% rename from server/helpers/channelPagination.js rename to server/controllers/utils/channelPagination.js diff --git a/server/helpers/authHelpers.js b/server/helpers/authHelpers.js deleted file mode 100644 index 029be2e0..00000000 --- a/server/helpers/authHelpers.js +++ /dev/null @@ -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); - }, -}; diff --git a/server/routes/api/channelAvailability.js b/server/routes/api/channelAvailability.js index b9f6230c..672bdcd0 100644 --- a/server/routes/api/channelAvailability.js +++ b/server/routes/api/channelAvailability.js @@ -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'); /* diff --git a/server/routes/api/channelClaims.js b/server/routes/api/channelClaims.js index 55986dbf..980d3e8e 100644 --- a/server/routes/api/channelClaims.js +++ b/server/routes/api/channelClaims.js @@ -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'; diff --git a/server/routes/api/channelData.js b/server/routes/api/channelData.js index de12b340..8f14cd47 100644 --- a/server/routes/api/channelData.js +++ b/server/routes/api/channelData.js @@ -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'; diff --git a/server/routes/api/channelShortId.js b/server/routes/api/channelShortId.js index 9fc33a8f..c5575ab6 100644 --- a/server/routes/api/channelShortId.js +++ b/server/routes/api/channelShortId.js @@ -1,4 +1,4 @@ -const { handleErrorResponse } = require('../../helpers/errorHandlers.js'); +const { handleErrorResponse } = require('../utils/errorHandlers.js'); const db = require('../../models'); /* diff --git a/server/routes/api/claimAvailability.js b/server/routes/api/claimAvailability.js index bd8726bf..c4d05cdd 100644 --- a/server/routes/api/claimAvailability.js +++ b/server/routes/api/claimAvailability.js @@ -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'); /* diff --git a/server/routes/api/claimData.js b/server/routes/api/claimData.js index 9a3a5495..965336df 100644 --- a/server/routes/api/claimData.js +++ b/server/routes/api/claimData.js @@ -1,4 +1,4 @@ -const { handleErrorResponse } = require('../../helpers/errorHandlers.js'); +const { handleErrorResponse } = require('../utils/errorHandlers.js'); const db = require('../../models'); /* diff --git a/server/routes/api/claimGet.js b/server/routes/api/claimGet.js index 9317b717..1551b7f2 100644 --- a/server/routes/api/claimGet.js +++ b/server/routes/api/claimGet.js @@ -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'); /* diff --git a/server/routes/api/claimList.js b/server/routes/api/claimList.js index 005fb591..e5a54215 100644 --- a/server/routes/api/claimList.js +++ b/server/routes/api/claimList.js @@ -1,5 +1,5 @@ const { getClaimList } = require('../../helpers/lbryApi.js'); -const { handleErrorResponse } = require('../../helpers/errorHandlers.js'); +const { handleErrorResponse } = require('../utils/errorHandlers.js'); /* diff --git a/server/routes/api/claimLongId.js b/server/routes/api/claimLongId.js index a5dd5fa5..3286afae 100644 --- a/server/routes/api/claimLongId.js +++ b/server/routes/api/claimLongId.js @@ -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'; diff --git a/server/routes/api/claimPublish.js b/server/routes/api/claimPublish.js index 5f8135d7..c3074421 100644 --- a/server/routes/api/claimPublish.js +++ b/server/routes/api/claimPublish.js @@ -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'); /* diff --git a/server/routes/api/claimResolve.js b/server/routes/api/claimResolve.js index 3876bde7..8f8aeaf9 100644 --- a/server/routes/api/claimResolve.js +++ b/server/routes/api/claimResolve.js @@ -1,5 +1,5 @@ const { resolveUri } = require('../../helpers/lbryApi.js'); -const { handleErrorResponse } = require('../../helpers/errorHandlers.js'); +const { handleErrorResponse } = require('../utils/errorHandlers.js'); /* diff --git a/server/routes/api/claimShortId.js b/server/routes/api/claimShortId.js index 1b28f519..db4833ba 100644 --- a/server/routes/api/claimShortId.js +++ b/server/routes/api/claimShortId.js @@ -1,4 +1,4 @@ -const { handleErrorResponse } = require('../../helpers/errorHandlers.js'); +const { handleErrorResponse } = require('../utils/errorHandlers.js'); const db = require('../../models'); /* diff --git a/server/routes/api/fileAvailability.js b/server/routes/api/fileAvailability.js index 153a60b9..f5cdb5bc 100644 --- a/server/routes/api/fileAvailability.js +++ b/server/routes/api/fileAvailability.js @@ -1,4 +1,4 @@ -const { handleErrorResponse } = require('../../helpers/errorHandlers.js'); +const { handleErrorResponse } = require('../utils/errorHandlers.js'); const db = require('../../models'); /* diff --git a/server/routes/assets/serveAssetByClaim.js b/server/routes/assets/serveAssetByClaim.js index 26c1a995..fa73c031 100644 --- a/server/routes/assets/serveAssetByClaim.js +++ b/server/routes/assets/serveAssetByClaim.js @@ -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'; diff --git a/server/routes/assets/serveAssetByIdentifierAndClaim.js b/server/routes/assets/serveAssetByIdentifierAndClaim.js index 470a0be7..71c2d413 100644 --- a/server/routes/assets/serveAssetByIdentifierAndClaim.js +++ b/server/routes/assets/serveAssetByIdentifierAndClaim.js @@ -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'; diff --git a/server/helpers/errorHandlers.js b/server/routes/utils/errorHandlers.js similarity index 100% rename from server/helpers/errorHandlers.js rename to server/routes/utils/errorHandlers.js diff --git a/server/helpers/lbryUri.js b/server/routes/utils/lbryUri.js similarity index 100% rename from server/helpers/lbryUri.js rename to server/routes/utils/lbryUri.js diff --git a/server/helpers/serveHelpers.js b/server/routes/utils/serve.js similarity index 97% rename from server/helpers/serveHelpers.js rename to server/routes/utils/serve.js index 4a425327..a5c9acd0 100644 --- a/server/helpers/serveHelpers.js +++ b/server/routes/utils/serve.js @@ -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'; diff --git a/server/speechPassport/index.js b/server/speechPassport/index.js index 3c60d3bc..60ec1808 100644 --- a/server/speechPassport/index.js +++ b/server/speechPassport/index.js @@ -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); diff --git a/server/speechPassport/utils/deserializeUser.js b/server/speechPassport/utils/deserializeUser.js new file mode 100644 index 00000000..34cecfa1 --- /dev/null +++ b/server/speechPassport/utils/deserializeUser.js @@ -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; diff --git a/server/speechPassport/local-login.js b/server/speechPassport/utils/local-login.js similarity index 97% rename from server/speechPassport/local-login.js rename to server/speechPassport/utils/local-login.js index 42be4b47..a8a11b8f 100644 --- a/server/speechPassport/local-login.js +++ b/server/speechPassport/utils/local-login.js @@ -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) => { diff --git a/server/speechPassport/local-signup.js b/server/speechPassport/utils/local-signup.js similarity index 96% rename from server/speechPassport/local-signup.js rename to server/speechPassport/utils/local-signup.js index 07971a9e..cabb0b0f 100644 --- a/server/speechPassport/local-signup.js +++ b/server/speechPassport/utils/local-signup.js @@ -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( { diff --git a/server/speechPassport/utils/serializeUser.js b/server/speechPassport/utils/serializeUser.js new file mode 100644 index 00000000..ce3cc719 --- /dev/null +++ b/server/speechPassport/utils/serializeUser.js @@ -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;