Ghost/core/server/api/canary/preview.js
Brilliant Djaka fc55089266
Replaced i18n.t w/ tpl helper in preview.js (#13494)
refs: #13380

The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:32:51 +01:00

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;
});
}
}
};