Skip to content

Commit

Permalink
better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech committed Jul 31, 2018
1 parent bba8ffb commit 02fd776
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/basic-custominstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Custom Hemera instance', function() {
await server.register({
plugin: HapiHemera,
options: {
hemeraInstance: hemeraInstance
hemeraInstance
}
})
await server.stop()
Expand All @@ -42,7 +42,7 @@ describe('Custom Hemera instance', function() {
await server.register({
plugin: HapiHemera,
options: {
hemeraInstance: hemeraInstance
hemeraInstance
}
})

Expand Down

0 comments on commit 02fd776

Please sign in to comment.