From 2e4e43b9f7f663a2b6bfedd38ad9577a3a774652 Mon Sep 17 00:00:00 2001 From: MJEND7 <60278279+MJEND7@users.noreply.github.com> Date: Tue, 31 Aug 2021 10:28:27 +1000 Subject: [PATCH 1/4] Update index.js --- server/plugins/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/plugins/index.js b/server/plugins/index.js index 90ce801f0..028cc3cf8 100644 --- a/server/plugins/index.js +++ b/server/plugins/index.js @@ -1,7 +1,7 @@ module.exports = registerPlugins -var log = require('npmlog') -var requireResolve = require('./resolver') +const log = require('npmlog') +const requireResolve = require('./resolver') function checkModule (modulePath) { try { @@ -16,11 +16,11 @@ function checkModule (modulePath) { } function registerPlugins (server, options, callback) { - var hapiPlugins = [ + const hapiPlugins = [ require('inert') ] - var localPlugins = [ + let localPlugins = [ './client', './logger', './maybe-force-gzip', @@ -32,14 +32,14 @@ function registerPlugins (server, options, callback) { } }) - var externalPlugins = options.plugins + const externalPlugins = options.plugins .filter(function (pluginPath) { return checkModule(pluginPath + '/hoodie/server') }) .map(function (pluginPath) { - var pkg = require(pluginPath + '/package.json') - var pluginName = pkg.hoodie ? pkg.hoodie.name || pkg.name : pkg.name - var hapiPluginOptions = require(pluginPath + '/hoodie/server') + let pkg = require(pluginPath + '/package.json') + let pluginName = pkg.hoodie ? pkg.hoodie.name || pkg.name : pkg.name + let hapiPluginOptions = require(pluginPath + '/hoodie/server') if (!hapiPluginOptions.register) { hapiPluginOptions = { register: hapiPluginOptions } @@ -51,16 +51,16 @@ function registerPlugins (server, options, callback) { return hapiPluginOptions }) - var plugins = hapiPlugins.concat(localPlugins, externalPlugins) + const plugins = hapiPlugins.concat(localPlugins, externalPlugins) - log.silly('hapi', 'Registering plugins') + log.silly('hapi', 'Registering plugins :D') server.register(plugins, function (error) { if (error) { return callback(error) } - log.info('hapi', 'plugins registered') + log.info('hapi', 'plugins registered :D') callback(null) }) } From a930044597a395088052e466666e86b68d3a6810 Mon Sep 17 00:00:00 2001 From: MJEND7 <60278279+MJEND7@users.noreply.github.com> Date: Tue, 31 Aug 2021 10:35:13 +1000 Subject: [PATCH 2/4] Updated logger changed vars to const/let Updated logger changed vars to const/let , simply changed var to const/let to prevent any odd errors from occurring --- server/plugins/logger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/plugins/logger.js b/server/plugins/logger.js index 99ccf81fe..08aa6415b 100644 --- a/server/plugins/logger.js +++ b/server/plugins/logger.js @@ -3,7 +3,7 @@ module.exports.register.attributes = { name: 'hoodie-local-logger' } -var path = require('path') +const path = require('path') function register (server, options, next) { server.register({ From eff5bfe56791700c43823d1009dc0421ee7c07e8 Mon Sep 17 00:00:00 2001 From: MJEND7 <60278279+MJEND7@users.noreply.github.com> Date: Tue, 31 Aug 2021 10:36:33 +1000 Subject: [PATCH 3/4] Updated public var's to const/let Updated public var's to const/let , simply changed var to const/let to prevent any odd errors from occurring --- server/plugins/public.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/server/plugins/public.js b/server/plugins/public.js index a0f249eda..c0317fdd9 100644 --- a/server/plugins/public.js +++ b/server/plugins/public.js @@ -4,25 +4,25 @@ module.exports.register.attributes = { dependencies: 'inert' } -var path = require('path') -var requireResolve = require('./resolver') -var createReadStream = require('fs').createReadStream +const path = require('path') +const requireResolve = require('./resolver') +const createReadStream = require('fs').createReadStream function register (server, options, next) { - var paths = options.paths - var plugins = options.plugins - var publicFolder = paths.public + let paths = options.paths + let plugins = options.plugins + let publicFolder = paths.public - var hoodieVersion + const hoodieVersion try { hoodieVersion = require('hoodie/package.json').version } catch (err) { hoodieVersion = 'development' } - var hoodiePublicPath = path.join(requireResolve('../../package.json'), '..', 'public') - var adminPublicPath = path.join(requireResolve('@hoodie/admin/package.json'), '..', 'dist') - var routes = [{ + const hoodiePublicPath = path.join(requireResolve('../../package.json'), '..', 'public') + const adminPublicPath = path.join(requireResolve('@hoodie/admin/package.json'), '..', 'dist') + let routes = [{ method: 'GET', path: '/{p*}', handler: { @@ -79,9 +79,9 @@ function register (server, options, next) { return } - var pkg = require(pluginPackagePath) + const pkg = require(pluginPackagePath) - var name = pkg.hoodie ? pkg.hoodie.name || pkg.name : pkg.name + const name = pkg.hoodie ? pkg.hoodie.name || pkg.name : pkg.name routes.push({ method: 'GET', @@ -100,18 +100,18 @@ function register (server, options, next) { // serve app whenever an html page is requested // and no other document is available - var app = path.join(publicFolder, 'index.html') + const app = path.join(publicFolder, 'index.html') server.ext('onPostHandler', function (request, reply) { - var response = request.response + let response = request.response if (!response.isBoom) { return reply.continue() } - var is404 = response.output.statusCode === 404 - var isHtmlRequest = /text\/html/.test(request.headers.accept) - var isHoodiePath = /^\/hoodie\//.test(request.path) - var isAdminPublicPath = /^\/hoodie\/admin\//.test(request.path) && !(/^\/hoodie\/admin\/api\//).test(request.path) + const is404 = response.output.statusCode === 404 + const isHtmlRequest = /text\/html/.test(request.headers.accept) + const isHoodiePath = /^\/hoodie\//.test(request.path) + const isAdminPublicPath = /^\/hoodie\/admin\//.test(request.path) && !(/^\/hoodie\/admin\/api\//).test(request.path) if (isAdminPublicPath && isHtmlRequest) { return reply(createReadStream(path.join(adminPublicPath, 'index.html'))) From a4610eb002ee9c92b457df3b8da115c5568751e6 Mon Sep 17 00:00:00 2001 From: MJEND7 <60278279+MJEND7@users.noreply.github.com> Date: Tue, 31 Aug 2021 10:37:47 +1000 Subject: [PATCH 4/4] Updated good-hoodie changed var to const/let Updated good-hoodie , simply changed var to const/let to prevent any odd errors from occurring --- server/plugins/good-hoodie.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/server/plugins/good-hoodie.js b/server/plugins/good-hoodie.js index faeea3b77..e8a715176 100644 --- a/server/plugins/good-hoodie.js +++ b/server/plugins/good-hoodie.js @@ -1,8 +1,7 @@ -var Transform = require('stream').Transform -var util = require('util') - -var log = require('npmlog') -var qs = require('querystring') +const Transform = require('stream').Transform +const util = require('util') +const log = require('npmlog') +const qs = require('querystring') function HoodieTransform () { if (!(this instanceof HoodieTransform)) { @@ -27,7 +26,7 @@ function transform (data, enc, next) { } if (data.event === 'response') { - var path = data.path + + let path = data.path + (Object.keys(data.query).length ? '?' + qs.stringify(data.query) : '') log.http( data.event, @@ -41,7 +40,7 @@ function transform (data, enc, next) { } if (data.event === 'request' || data.event === 'log') { - var level = findLogLevel(Object.keys(log.levels), data.tags) || 'verbose' + let level = findLogLevel(Object.keys(log.levels), data.tags) || 'verbose' log[level]( data.event, new Date(data.timestamp).toISOString(), @@ -55,8 +54,8 @@ function transform (data, enc, next) { } function findLogLevel (levels, tags) { - for (var i = 0; i < tags.length; i++) { - for (var j = 0; j < levels.length; j++) { + for (let i = 0; i < tags.length; i++) { + for (let j = 0; j < levels.length; j++) { if (levels[j] === tags[i]) { tags.splice(i, 1) return levels[j]