mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
25 lines
759 B
JavaScript
25 lines
759 B
JavaScript
|
const models = require('../../../models');
|
||
|
const i18n = require('../../../../shared/i18n');
|
||
|
const errors = require('@tryghost/errors');
|
||
|
|
||
|
/**
|
||
|
* @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: i18n.t('errors.api.resource.resourceNotFound', {
|
||
|
resource: 'Integration'
|
||
|
})
|
||
|
});
|
||
|
}
|
||
|
return integration.toJSON();
|
||
|
});
|
||
|
};
|
||
|
|
||
|
module.exports = getSchedulerIntegration;
|