1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat: stateServices only exposed via services object

This commit is contained in:
Ivar Conradi Østhus 2020-11-23 21:52:57 +01:00
parent 19b92ebd5b
commit 5f2b684f57
2 changed files with 9 additions and 11 deletions

View File

@ -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.

View File

@ -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) {