From 2da26e7f14354a810d9413dd0a081711796c7eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Fri, 18 Jun 2021 11:53:52 +0200 Subject: [PATCH] fix: refactor code --- src/lib/server-impl.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/lib/server-impl.ts b/src/lib/server-impl.ts index a9826bee7d..cf0c47bbda 100644 --- a/src/lib/server-impl.ts +++ b/src/lib/server-impl.ts @@ -1,5 +1,3 @@ -'use strict'; - import EventEmitter from 'events'; import stoppable, { StoppableServer } from 'stoppable'; import { promisify } from 'util'; @@ -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 { - const { db, clientInstanceStore, clientMetricsStore } = stores; - clientInstanceStore.destroy(); - clientMetricsStore.destroy(); - await db.destroy(); -} async function createApp( config: IUnleashConfig, @@ -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) {