mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
bf295a96a8
refs #10060
68 lines
2.0 KiB
JavaScript
68 lines
2.0 KiB
JavaScript
const Promise = require('bluebird');
|
|
const {isPlainObject} = require('lodash');
|
|
const urlService = require('../../services/url');
|
|
const models = require('../../models');
|
|
const config = require('../../config');
|
|
const labs = require('../../services/labs');
|
|
const settingsCache = require('../../services/settings/cache');
|
|
const ghostVersion = require('../../lib/ghost-version');
|
|
|
|
function fetchAvailableTimezones() {
|
|
const timezones = require('../../data/timezones.json');
|
|
return timezones;
|
|
}
|
|
|
|
function getAboutConfig() {
|
|
return {
|
|
version: ghostVersion.full,
|
|
environment: config.get('env'),
|
|
database: config.get('database').client,
|
|
mail: isPlainObject(config.get('mail')) ? config.get('mail').transport : ''
|
|
};
|
|
}
|
|
|
|
function getBaseConfig() {
|
|
return {
|
|
useGravatar: !config.isPrivacyDisabled('useGravatar'),
|
|
publicAPI: labs.isSet('publicAPI'),
|
|
blogUrl: urlService.utils.urlFor('home', true),
|
|
blogTitle: settingsCache.get('title'),
|
|
clientExtensions: config.get('clientExtensions'),
|
|
enableDeveloperExperiments: config.get('enableDeveloperExperiments')
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
docName: 'configuration',
|
|
read: {
|
|
permissions: false,
|
|
data: [
|
|
'key'
|
|
],
|
|
query({data}) {
|
|
if (!data.key) {
|
|
return models.Client.findOne({slug: 'ghost-admin'})
|
|
.then((ghostAdmin) => {
|
|
const configuration = getBaseConfig();
|
|
|
|
configuration.clientId = ghostAdmin.get('slug');
|
|
configuration.clientSecret = ghostAdmin.get('secret');
|
|
|
|
return configuration;
|
|
});
|
|
}
|
|
|
|
if (data.key === 'about') {
|
|
return Promise.resolve(getAboutConfig());
|
|
}
|
|
|
|
// Timezone endpoint
|
|
if (data.key === 'timezones') {
|
|
return Promise.resolve(fetchAvailableTimezones());
|
|
}
|
|
|
|
return Promise.resolve();
|
|
}
|
|
}
|
|
};
|