Ghost/core/server/services/themes/index.js
Hannah Wolfe 4da7e7f0cb
Rework the themeService public API
refs: https://github.com/TryGhost/Team/issues/831

- This ultimately fixes the index.js file
- It also makes it super clear what methods in the themeService are used by the API, and which are part of the service loading logic
- It also moves the activate and init function into a single file in a way that highlights they are very similar
- They are also very similar to what happens in storage.setFromZip but that code is mixed up with storage code at the moment
2021-07-07 15:02:02 +01:00

32 lines
767 B
JavaScript

const activate = require('./activate');
const themeLoader = require('./loader');
const storage = require('./storage');
const getJSON = require('./to-json');
const settingsCache = require('../../../shared/settings-cache');
module.exports = {
/*
* Load the currently active theme
*/
init: async () => {
const themeName = settingsCache.get('active_theme');
return activate.loadAndActivate(themeName);
},
/**
* Load all inactive themes
*/
loadInactiveThemes: themeLoader.loadAllThemes,
/**
* Methods used in the API
*/
api: {
getJSON,
activate: activate.activate,
getZip: storage.getZip,
setFromZip: storage.setFromZip,
destroy: storage.destroy
}
};