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:
parent
64738adfc0
commit
8bfcc37ad4
1 changed files with 0 additions and 50 deletions
|
@ -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
|
||||
};
|
Loading…
Add table
Reference in a new issue