mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
829e8ed010
- Having these as destructured from the same package is hindering refactoring now - Events should really only ever be used server-side - i18n should be a shared module for now so it can be used everywhere until we figure out something better - Having them seperate also allows us to lint them properly
66 lines
1.5 KiB
JavaScript
66 lines
1.5 KiB
JavaScript
const Promise = require('bluebird');
|
|
const i18n = require('../../lib/common/i18n');
|
|
const errors = require('@tryghost/errors');
|
|
const models = require('../../models');
|
|
const ALLOWED_INCLUDES = ['count.posts'];
|
|
|
|
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: i18n.t('errors.api.authors.notFound')
|
|
}));
|
|
}
|
|
|
|
return model;
|
|
});
|
|
}
|
|
}
|
|
};
|