Moved serve-favicon mw into site app

- Moved serve-favicon from shared to site as it is not shared
- This file is only used in one place, this updates the code structure to reflect this
- This is one of many similar changes needed to make it easier to refactor to the existing setup
This commit is contained in:
Hannah Wolfe 2020-04-21 14:27:56 +01:00
parent c54e50bd11
commit 40fa2053e3
5 changed files with 13 additions and 16 deletions

View File

@ -55,10 +55,6 @@ module.exports = {
return require('./request-id');
},
get serveFavicon() {
return require('./serve-favicon');
},
get servePublicFile() {
return require('./serve-public-file');
},

View File

@ -106,7 +106,7 @@ module.exports = function setupSiteApp(options = {}) {
// Static content/assets
// @TODO make sure all of these have a local 404 error handler
// Favicon
siteApp.use(shared.middlewares.serveFavicon());
siteApp.use(mw.serveFavicon());
// /public/members.js
siteApp.get('/public/members.js', membersMiddleware.public);

View File

@ -1,3 +1,4 @@
module.exports = {
adminRedirects: require('./admin-redirects')
adminRedirects: require('./admin-redirects'),
serveFavicon: require('./serve-favicon')
};

View File

@ -1,10 +1,10 @@
var should = require('should'),
sinon = require('sinon'),
express = require('express'),
serveFavicon = require('../../../../core/server/web/shared/middlewares/serve-favicon'),
settingsCache = require('../../../../core/server/services/settings/cache'),
storage = require('../../../../core/server/adapters/storage'),
configUtils = require('../../../utils/configUtils'),
serveFavicon = require('../../../../../core/server/web/site/middleware/serve-favicon'),
settingsCache = require('../../../../../core/server/services/settings/cache'),
storage = require('../../../../../core/server/adapters/storage'),
configUtils = require('../../../../utils/configUtils'),
path = require('path');
describe('Serve Favicon', function () {
@ -50,7 +50,7 @@ describe('Serve Favicon', function () {
var middleware = serveFavicon();
req.path = '/favicon.png';
storage.getStorage().storagePath = path.join(__dirname, '../../../../test/utils/fixtures/images/');
storage.getStorage().storagePath = path.join(__dirname, '../../../../../test/utils/fixtures/images/');
localSettingsCache.icon = 'favicon.png';
res = {
@ -70,7 +70,7 @@ describe('Serve Favicon', function () {
var middleware = serveFavicon();
req.path = '/favicon.ico';
storage.getStorage().storagePath = path.join(__dirname, '../../../../test/utils/fixtures/images/');
storage.getStorage().storagePath = path.join(__dirname, '../../../../../test/utils/fixtures/images/');
localSettingsCache.icon = 'favicon.ico';
res = {
@ -90,7 +90,7 @@ describe('Serve Favicon', function () {
var middleware = serveFavicon();
req.path = '/favicon.ico';
storage.getStorage().storagePath = path.join(__dirname, '../../../../test/utils/fixtures/images/');
storage.getStorage().storagePath = path.join(__dirname, '../../../../../test/utils/fixtures/images/');
localSettingsCache.icon = 'myicon.ico';
res = {
@ -130,7 +130,7 @@ describe('Serve Favicon', function () {
var middleware = serveFavicon();
req.path = '/favicon.png';
configUtils.set('paths:contentPath', path.join(__dirname, '../../../../test/utils/fixtures/'));
configUtils.set('paths:contentPath', path.join(__dirname, '../../../../../test/utils/fixtures/'));
localSettingsCache.icon = 'favicon.ico';
res = {
@ -147,7 +147,7 @@ describe('Serve Favicon', function () {
var middleware = serveFavicon();
req.path = '/favicon.ico';
configUtils.set('paths:contentPath', path.join(__dirname, '../../../../test/utils/fixtures/'));
configUtils.set('paths:contentPath', path.join(__dirname, '../../../../../test/utils/fixtures/'));
localSettingsCache.icon = 'favicon.png';
res = {
@ -164,7 +164,7 @@ describe('Serve Favicon', function () {
var middleware = serveFavicon();
req.path = '/favicon.png';
configUtils.set('paths:publicFilePath', path.join(__dirname, '../../../../test/utils/fixtures/'));
configUtils.set('paths:publicFilePath', path.join(__dirname, '../../../../../test/utils/fixtures/'));
localSettingsCache.icon = '';
res = {