diff --git a/docs/import-export.md b/docs/import-export.md index a10c8ac764..c76826d3db 100644 --- a/docs/import-export.md +++ b/docs/import-export.md @@ -20,12 +20,14 @@ Unleash returns a StateService when started, you can use this to import and expo ```javascript const unleash = require('unleash-server'); -unleash.start({...}) - .then(async ({ stateService }) => { - const exportedData = await stateService.export({includeStrategies: false, includeFeatureToggles: true}); - await stateService.import({data: exportedData, userName: 'import', dropBeforeImport: false}); - await stateService.importFile({file: 'exported-data.yml', userName: 'import', dropBeforeImport: true}) - }); +const { services } = await unleash.start({...}); +const { stateService } = services; + +const exportedData = await stateService.export({includeStrategies: false, includeFeatureToggles: true}); + +await stateService.import({data: exportedData, userName: 'import', dropBeforeImport: false}); + +await stateService.importFile({file: 'exported-data.yml', userName: 'import', dropBeforeImport: true}) ``` If you want the database to be cleaned before import (all strategies and features will be removed), set the `dropBeforeImport` parameter. diff --git a/lib/server-impl.js b/lib/server-impl.js index c1b0cda92b..4468a5596f 100644 --- a/lib/server-impl.js +++ b/lib/server-impl.js @@ -39,11 +39,8 @@ async function createApp(options) { addEventHook(config.eventHook, stores.eventStore); } - // TODO: refactor this. Should only be accessable via services object - const { stateService } = services; - config.stateService = stateService; if (config.importFile) { - await stateService.importFile({ + await services.stateService.importFile({ file: config.importFile, dropBeforeImport: config.dropBeforeImport, userName: 'import', @@ -58,7 +55,6 @@ async function createApp(options) { stores, services, eventBus, - stateService, }; if (options.start) {