Ghost/core/server/api/canary/email.js
2019-11-06 15:56:56 +07:00

34 lines
843 B
JavaScript

const models = require('../../models');
const common = require('../../lib/common');
module.exports = {
docName: 'emails',
read: {
options: [
'fields'
],
validation: {
options: {
fields: ['html', 'plaintext', 'subject']
}
},
data: [
'id'
],
permissions: true,
query(frame) {
return models.Email.findOne(frame.data, frame.options)
.then((model) => {
if (!model) {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.api.email.emailNotFound')
});
}
return model.toJSON(frame.options);
});
}
}
};