From 02fd776331d17bccf39259c88831361ed2e0ab50 Mon Sep 17 00:00:00 2001 From: starptech Date: Tue, 31 Jul 2018 08:07:15 +0200 Subject: [PATCH] better naming --- lib/index.js | 12 ++++++------ test/basic-custominstance.js | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/index.js b/lib/index.js index 9f2e9c9..e75be40 100644 --- a/lib/index.js +++ b/lib/index.js @@ -19,11 +19,11 @@ const internals = { async function register(server, options) { const settings = Hoek.applyToDefaults(internals.defaults, options) - const createHemera = !options.hemeraInstance + const useHemeraInstance = !!options.hemeraInstance - const hemera = createHemera - ? new Hemera(Nats.connect(settings.nats), settings.hemera) - : options.hemeraInstance + const hemera = useHemeraInstance + ? options.hemeraInstance + : new Hemera(Nats.connect(settings.nats), settings.hemera) hemera.on('serverResponseError', error => server.log(['hemera', 'serverResponseError'], error) @@ -32,7 +32,7 @@ async function register(server, options) { server.log(['hemera', 'clientResponseError'], error) ) - if (createHemera && options.plugins) { + if (useHemeraInstance === false && options.plugins) { options.plugins.forEach(plugin => { if (plugin.options) { hemera.use(plugin.register, plugin.options) @@ -79,7 +79,7 @@ async function register(server, options) { return hemera.close() }) - if (createHemera) await hemera.ready() + if (useHemeraInstance === false) await hemera.ready() } internals.handler = function(route, options) { diff --git a/test/basic-custominstance.js b/test/basic-custominstance.js index 42832df..9f09f66 100644 --- a/test/basic-custominstance.js +++ b/test/basic-custominstance.js @@ -30,7 +30,7 @@ describe('Custom Hemera instance', function() { await server.register({ plugin: HapiHemera, options: { - hemeraInstance: hemeraInstance + hemeraInstance } }) await server.stop() @@ -42,7 +42,7 @@ describe('Custom Hemera instance', function() { await server.register({ plugin: HapiHemera, options: { - hemeraInstance: hemeraInstance + hemeraInstance } })