mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-04 17:04:59 +03:00
c02ebb0dcf
closes #2610, refs #2697 - cleanup API index.js, and add docs - all API methods take consistent arguments: object & options - browse, read, destroy take options, edit and add take object and options - the context is passed as part of options, meaning no more .call everywhere - destroy expects an object, rather than an id all the way down to the model layer - route params such as :id, :slug, and :key are passed as an option & used to perform reads, updates and deletes where possible - settings / themes may need work here still - HTTP posts api can find a post by slug - Add API utils for checkData
14 lines
418 B
JavaScript
14 lines
418 B
JavaScript
var when = require('when'),
|
|
_ = require('lodash'),
|
|
utils;
|
|
|
|
utils = {
|
|
checkObject: function (object, docName) {
|
|
if (_.isEmpty(object) || _.isEmpty(object[docName]) || _.isEmpty(object[docName][0])) {
|
|
return when.reject({type: 'BadRequest', message: 'No root key (\'' + docName + '\') provided.'});
|
|
}
|
|
return when.resolve(object);
|
|
}
|
|
};
|
|
|
|
module.exports = utils; |