0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/adapters/scheduling/post-scheduling/scheduler-intergation.js

27 lines
755 B
JavaScript
Raw Normal View History

const models = require('../../../models');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const messages = {
resourceNotFound: '{resource} not found.'
};
/**
* @description Load the internal scheduler integration
*
* @return {Promise}
*/
const getSchedulerIntegration = function () {
return models.Integration.findOne({slug: 'ghost-scheduler'}, {withRelated: 'api_keys'})
.then((integration) => {
if (!integration) {
throw new errors.NotFoundError({
message: tpl(messages.resourceNotFound, {resource: 'Integration'})
});
}
return integration.toJSON();
});
};
module.exports = getSchedulerIntegration;