Skip to content

Commit

Permalink
fix: refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarconr committed Jun 18, 2021
1 parent 4f9deee commit 2da26e7
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/lib/server-impl.ts
@@ -1,5 +1,3 @@
'use strict';

import EventEmitter from 'events';
import stoppable, { StoppableServer } from 'stoppable';
import { promisify } from 'util';
Expand All @@ -19,14 +17,6 @@ import AuthenticationRequired from './types/authentication-required';
import * as eventType from './types/events';
import { addEventHook } from './event-hook';
import registerGracefulShutdown from './util/graceful-shutdown';
import { IUnleashStores } from './types/stores';

async function destroyDatabase(stores: IUnleashStores): Promise<void> {
const { db, clientInstanceStore, clientMetricsStore } = stores;
clientInstanceStore.destroy();
clientMetricsStore.destroy();
await db.destroy();
}

async function createApp(
config: IUnleashConfig,
Expand All @@ -47,7 +37,9 @@ async function createApp(
await stopServer();
}
metricsMonitor.stopMonitoring();
await destroyDatabase(stores);
stores.clientInstanceStore.destroy();
stores.clientMetricsStore.destroy();
await stores.db.destroy();
};

if (!config.server.secret) {
Expand Down

0 comments on commit 2da26e7

Please sign in to comment.