0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

Removed lib/util

no-issue

This is no longer used
This commit is contained in:
Fabien O'Carroll 2019-09-06 13:06:53 +08:00
parent 64738adfc0
commit 8bfcc37ad4

View file

@ -1,50 +0,0 @@
const common = require('./common');
function getData(...props) {
return function (req, res, next) {
if (!req.body) {
res.writeHead(400);
return res.end();
}
const data = props.concat('origin').reduce((data, prop) => {
if (!data) {
return null;
}
let propObj = typeof prop === 'string' ? {
name: prop,
required: true
} : prop;
const value = req.body[propObj.name];
if (propObj.required && !value) {
return null;
}
return Object.assign(data, {
[propObj.name]: value
});
}, {});
if (!data) {
res.writeHead(400);
return res.end(`Expected {${props.join(', ')}}`);
}
req.data = data || {};
next();
};
}
function handleError(status, res) {
return function (err) {
common.logging.error(err);
res.writeHead(status);
res.end();
};
}
module.exports = {
getData,
handleError
};