mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 13:52:10 +03:00
fc55089266
refs: #13380 The i18n package is deprecated. It is being replaced with the tpl package.
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
const tpl = require('@tryghost/tpl');
|
|
const errors = require('@tryghost/errors');
|
|
const models = require('../../models');
|
|
const ALLOWED_INCLUDES = ['authors', 'tags'];
|
|
|
|
const messages = {
|
|
postNotFound: 'Post not found.'
|
|
};
|
|
|
|
module.exports = {
|
|
docName: 'preview',
|
|
|
|
read: {
|
|
permissions: true,
|
|
options: [
|
|
'include'
|
|
],
|
|
data: [
|
|
'uuid'
|
|
],
|
|
validation: {
|
|
options: {
|
|
include: {
|
|
values: ALLOWED_INCLUDES
|
|
}
|
|
},
|
|
data: {
|
|
uuid: {
|
|
required: true
|
|
}
|
|
}
|
|
},
|
|
query(frame) {
|
|
return models.Post.findOne(Object.assign({status: 'all'}, frame.data), frame.options)
|
|
.then((model) => {
|
|
if (!model) {
|
|
throw new errors.NotFoundError({
|
|
message: tpl(messages.postNotFound)
|
|
});
|
|
}
|
|
|
|
return model;
|
|
});
|
|
}
|
|
}
|
|
};
|