mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
7b761a8751
no issue Adds new canary api endpoint, currently replicating v2 endpoint but paving way for future updates to new version
65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
const Promise = require('bluebird');
|
|
const common = require('../../lib/common');
|
|
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 common.errors.NotFoundError({
|
|
message: common.i18n.t('errors.api.authors.notFound')
|
|
}));
|
|
}
|
|
|
|
return model;
|
|
});
|
|
}
|
|
}
|
|
};
|