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:
parent
19b92ebd5b
commit
5f2b684f57
@ -20,12 +20,14 @@ Unleash returns a StateService when started, you can use this to import and expo
|
|||||||
```javascript
|
```javascript
|
||||||
const unleash = require('unleash-server');
|
const unleash = require('unleash-server');
|
||||||
|
|
||||||
unleash.start({...})
|
const { services } = await unleash.start({...});
|
||||||
.then(async ({ stateService }) => {
|
const { stateService } = services;
|
||||||
const exportedData = await stateService.export({includeStrategies: false, includeFeatureToggles: true});
|
|
||||||
await stateService.import({data: exportedData, userName: 'import', dropBeforeImport: false});
|
const exportedData = await stateService.export({includeStrategies: false, includeFeatureToggles: true});
|
||||||
await stateService.importFile({file: 'exported-data.yml', userName: 'import', dropBeforeImport: 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.
|
If you want the database to be cleaned before import (all strategies and features will be removed), set the `dropBeforeImport` parameter.
|
||||||
|
@ -39,11 +39,8 @@ async function createApp(options) {
|
|||||||
addEventHook(config.eventHook, stores.eventStore);
|
addEventHook(config.eventHook, stores.eventStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: refactor this. Should only be accessable via services object
|
|
||||||
const { stateService } = services;
|
|
||||||
config.stateService = stateService;
|
|
||||||
if (config.importFile) {
|
if (config.importFile) {
|
||||||
await stateService.importFile({
|
await services.stateService.importFile({
|
||||||
file: config.importFile,
|
file: config.importFile,
|
||||||
dropBeforeImport: config.dropBeforeImport,
|
dropBeforeImport: config.dropBeforeImport,
|
||||||
userName: 'import',
|
userName: 'import',
|
||||||
@ -58,7 +55,6 @@ async function createApp(options) {
|
|||||||
stores,
|
stores,
|
||||||
services,
|
services,
|
||||||
eventBus,
|
eventBus,
|
||||||
stateService,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.start) {
|
if (options.start) {
|
||||||
|
Loading…
Reference in New Issue
Block a user