2018-10-17 11:48:06 +02:00
|
|
|
const common = require('../../lib/common');
|
2018-10-05 00:50:45 +02:00
|
|
|
const models = require('../../models');
|
2018-12-17 17:45:07 +01:00
|
|
|
const ALLOWED_INCLUDES = ['author', 'tags', 'authors', 'authors.roles'];
|
2018-10-05 00:50:45 +02:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
docName: 'pages',
|
|
|
|
browse: {
|
|
|
|
options: [
|
|
|
|
'include',
|
|
|
|
'filter',
|
|
|
|
'status',
|
|
|
|
'fields',
|
|
|
|
'formats',
|
|
|
|
'absolute_urls',
|
|
|
|
'page',
|
|
|
|
'limit',
|
|
|
|
'order',
|
|
|
|
'debug'
|
|
|
|
],
|
|
|
|
validation: {
|
|
|
|
options: {
|
|
|
|
include: {
|
2018-10-17 11:48:06 +02:00
|
|
|
values: ALLOWED_INCLUDES
|
2018-10-05 00:50:45 +02:00
|
|
|
},
|
|
|
|
formats: {
|
|
|
|
values: models.Post.allowedFormats
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
permissions: true,
|
|
|
|
query(frame) {
|
|
|
|
return models.Post.findPage(frame.options);
|
|
|
|
}
|
2018-10-17 11:48:06 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
read: {
|
|
|
|
options: [
|
|
|
|
'include',
|
|
|
|
'fields',
|
|
|
|
'status',
|
|
|
|
'formats',
|
2018-11-05 18:07:45 +01:00
|
|
|
'debug',
|
|
|
|
'absolute_urls'
|
2018-10-17 11:48:06 +02:00
|
|
|
],
|
|
|
|
data: [
|
|
|
|
'id',
|
|
|
|
'slug',
|
|
|
|
'status',
|
|
|
|
'uuid'
|
|
|
|
],
|
|
|
|
validation: {
|
|
|
|
options: {
|
|
|
|
include: {
|
|
|
|
values: ALLOWED_INCLUDES
|
|
|
|
},
|
|
|
|
formats: {
|
|
|
|
values: models.Post.allowedFormats
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
permissions: true,
|
|
|
|
query(frame) {
|
|
|
|
return models.Post.findOne(frame.data, frame.options)
|
|
|
|
.then((model) => {
|
|
|
|
if (!model) {
|
|
|
|
throw new common.errors.NotFoundError({
|
|
|
|
message: common.i18n.t('errors.api.pages.pageNotFound')
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return model;
|
|
|
|
});
|
|
|
|
}
|
2018-10-05 00:50:45 +02:00
|
|
|
}
|
|
|
|
};
|