mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
c1789a3a03
refs: #13380 - The i18n package is deprecated. It is being replaced with the tpl package. Co-authored-by: Shadman Khan <shadmankhan@ShadmanMac.local>
70 lines
1.5 KiB
JavaScript
70 lines
1.5 KiB
JavaScript
const Promise = require('bluebird');
|
|
const errors = require('@tryghost/errors');
|
|
const models = require('../../models');
|
|
const ALLOWED_INCLUDES = ['count.posts'];
|
|
const tpl = require('@tryghost/tpl');
|
|
|
|
const messages = {
|
|
notFound: 'Author not found.'
|
|
};
|
|
|
|
module.exports = {
|
|
docName: 'authors',
|
|
|
|
browse: {
|
|
options: [
|
|
'include',
|
|
'filter',
|
|
'fields',
|
|
'limit',
|
|
'order',
|
|
'page'
|
|
],
|
|
validation: {
|
|
options: {
|
|
include: {
|
|
values: ALLOWED_INCLUDES
|
|
}
|
|
}
|
|
},
|
|
permissions: true,
|
|
query(frame) {
|
|
return models.Author.findPage(frame.options);
|
|
}
|
|
},
|
|
|
|
read: {
|
|
options: [
|
|
'include',
|
|
'filter',
|
|
'fields'
|
|
],
|
|
data: [
|
|
'id',
|
|
'slug',
|
|
'email',
|
|
'role'
|
|
],
|
|
validation: {
|
|
options: {
|
|
include: {
|
|
values: ALLOWED_INCLUDES
|
|
}
|
|
}
|
|
},
|
|
permissions: true,
|
|
query(frame) {
|
|
return models.Author.findOne(frame.data, frame.options)
|
|
.then((model) => {
|
|
if (!model) {
|
|
return Promise.reject(new errors.NotFoundError({
|
|
message: tpl(messages.notFound)
|
|
}));
|
|
}
|
|
|
|
return model;
|
|
});
|
|
}
|
|
}
|
|
};
|