mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-15 03:01:37 -05:00
Removed unused middleware code
- removed empty theme-handler_spec.js file - removed unused export of uncapitalise - removed unused export of utils - remove unused blog-icon and profile-image validation code (now lives in core/server/api/[version]/utils/validators/input)
This commit is contained in:
parent
36b42505ea
commit
d85c634669
6 changed files with 0 additions and 91 deletions
core/server/web/shared
test/unit/web/middleware
|
@ -1,9 +1,5 @@
|
|||
module.exports = {
|
||||
get middlewares() {
|
||||
return require('./middlewares');
|
||||
},
|
||||
|
||||
get utils() {
|
||||
return require('./utils');
|
||||
}
|
||||
};
|
||||
|
|
|
@ -39,10 +39,6 @@ module.exports = {
|
|||
return require('./pretty-urls');
|
||||
},
|
||||
|
||||
get uncapitalise() {
|
||||
return require('./uncapitalise');
|
||||
},
|
||||
|
||||
get urlRedirects() {
|
||||
return require('./url-redirects');
|
||||
}
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
const errors = require('@tryghost/errors');
|
||||
const config = require('../../../../config');
|
||||
const {i18n} = require('../../../../lib/common');
|
||||
const imageLib = require('../../../../lib/image');
|
||||
|
||||
const validIconFileSize = (size) => {
|
||||
return (size / 1024) <= 100;
|
||||
};
|
||||
|
||||
module.exports = function blogIcon() {
|
||||
// we checked for a valid image file, now we need to do validations for blog icons
|
||||
return function blogIconValidation(req, res, next) {
|
||||
const iconExtensions = (config.get('uploads').icons && config.get('uploads').icons.extensions) || [];
|
||||
|
||||
// CASE: file should not be larger than 100kb
|
||||
if (!validIconFileSize(req.file.size)) {
|
||||
return next(new errors.ValidationError({
|
||||
message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
|
||||
}));
|
||||
}
|
||||
|
||||
return imageLib.blogIcon.getIconDimensions(req.file.path).then((response) => {
|
||||
// save the image dimensions in new property for file
|
||||
req.file.dimensions = response;
|
||||
|
||||
// CASE: file needs to be a square
|
||||
if (req.file.dimensions.width !== req.file.dimensions.height) {
|
||||
return next(new errors.ValidationError({
|
||||
message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
|
||||
}));
|
||||
}
|
||||
|
||||
// CASE: icon needs to be bigger than or equal to 60px
|
||||
// .ico files can contain multiple sizes, we need at least a minimum of 60px (16px is ok, as long as 60px are present as well)
|
||||
if (req.file.dimensions.width < 60) {
|
||||
return next(new errors.ValidationError({
|
||||
message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
|
||||
}));
|
||||
}
|
||||
|
||||
// CASE: icon needs to be smaller than or equal to 1000px
|
||||
if (req.file.dimensions.width > 1000) {
|
||||
return next(new errors.ValidationError({
|
||||
message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
|
||||
}));
|
||||
}
|
||||
|
||||
next();
|
||||
}).catch((err) => {
|
||||
next(err);
|
||||
});
|
||||
};
|
||||
};
|
|
@ -1,13 +1,5 @@
|
|||
module.exports = {
|
||||
get upload() {
|
||||
return require('./upload');
|
||||
},
|
||||
|
||||
get blogIcon() {
|
||||
return require('./blog-icon');
|
||||
},
|
||||
|
||||
get profileImage() {
|
||||
return require('./profile-image');
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
const errors = require('@tryghost/errors');
|
||||
const {i18n} = require('../../../../lib/common');
|
||||
const imageLib = require('../../../../lib/image');
|
||||
|
||||
module.exports = function profileImage(req, res, next) {
|
||||
// we checked for a valid image file, now we need to do validations for profile image
|
||||
imageLib.imageSize.getImageSizeFromPath(req.file.path).then((response) => {
|
||||
// save the image dimensions in new property for file
|
||||
req.file.dimensions = response;
|
||||
|
||||
// CASE: file needs to be a square
|
||||
if (req.file.dimensions.width !== req.file.dimensions.height) {
|
||||
return next(new errors.ValidationError({
|
||||
message: i18n.t('errors.api.images.isNotSquare')
|
||||
}));
|
||||
}
|
||||
|
||||
next();
|
||||
}).catch((err) => {
|
||||
next(err);
|
||||
});
|
||||
};
|
Loading…
Add table
Reference in a new issue