From 8bfcc37ad403b4cb075ac0e3e674ea530f9ccf7b Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Fri, 6 Sep 2019 13:06:53 +0800 Subject: [PATCH] Removed lib/util no-issue This is no longer used --- ghost/members-api/lib/util.js | 50 ----------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 ghost/members-api/lib/util.js diff --git a/ghost/members-api/lib/util.js b/ghost/members-api/lib/util.js deleted file mode 100644 index a4be565fef..0000000000 --- a/ghost/members-api/lib/util.js +++ /dev/null @@ -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 -};