Moved normalize image mw into api app

- Moved normalize image mw from shared to api as it is not shared (except within the API)
- This file is only used in one part of the app, 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-22 17:34:11 +01:00
parent d0a16112f5
commit f4f61b8a3a
7 changed files with 6 additions and 14 deletions

View File

@ -196,7 +196,7 @@ module.exports = function apiRoutes() {
mw.authAdminApi,
apiMw.upload.single('file'),
apiMw.upload.validation({type: 'images'}),
shared.middlewares.image.normalize,
apiMw.normalizeImage,
http(apiCanary.images.upload)
);

View File

@ -1,5 +1,6 @@
module.exports = {
cors: require('./cors'),
normalizeImage: require('./normalize-image'),
updateUserLastSeen: require('./update-user-last-seen'),
upload: require('./upload'),
versionMatch: require('./version-match')

View File

@ -1,6 +1,6 @@
const cloneDeep = require('lodash/cloneDeep');
const config = require('../../../../config');
const {logging} = require('../../../../lib/common');
const config = require('../../../config');
const {logging} = require('../../../lib/common');
const imageTransform = require('@tryghost/image-transform');
module.exports = function normalize(req, res, next) {

View File

@ -166,7 +166,7 @@ module.exports = function apiRoutes() {
mw.authAdminApi,
apiMw.upload.single('file'),
apiMw.upload.validation({type: 'images'}),
shared.middlewares.image.normalize,
apiMw.normalizeImage,
http(apiv2.images.upload)
);

View File

@ -1,5 +0,0 @@
module.exports = {
get normalize() {
return require('./normalize');
}
};

View File

@ -3,10 +3,6 @@ module.exports = {
return require('./api');
},
get image() {
return require('./image');
},
get brute() {
return require('./brute');
},

View File

@ -3,7 +3,7 @@ const sinon = require('sinon');
const configUtils = require('../../../../utils/configUtils');
const imageTransform = require('@tryghost/image-transform');
const {logging} = require('../../../../../core/server/lib/common');
const normalize = require('../../../../../core/server/web/shared/middlewares/image/normalize');
const normalize = require('../../../../../core/server/web/api/middleware/normalize-image');
describe('normalize', function () {
let res, req;