From 33b3d98a3716c3c5da67a9aa7889e89702f1d2af Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Sat, 2 Apr 2022 20:10:09 +0000 Subject: [PATCH] application: Expose app config in ctx.config --- core/application.mjs | 2 ++ package.json | 2 +- test/application.test.mjs | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/application.mjs b/core/application.mjs index 45c1bce..83e6ef5 100644 --- a/core/application.mjs +++ b/core/application.mjs @@ -55,6 +55,8 @@ export default class Application extends EventEmitter { this.config.heartbeatPath = this.config.heartbeatPath || '/' this.config.clusterWaitOnCrash = this.config.clusterWaitOnCrash || (1 * 1000) + this.ctx.config = this.config + Object.assign(this, { setInterval: opts.setInterval || setInterval, setTimeout: opts.setTimeout || setTimeout, diff --git a/package.json b/package.json index 6a9e5db..20db506 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "service-core", - "version": "3.0.0-beta.15", + "version": "3.0.0-beta.16", "description": "Core boiler plate code to install node server as windows service", "main": "index.mjs", "scripts": { diff --git a/test/application.test.mjs b/test/application.test.mjs index 2027cfd..ee476cb 100644 --- a/test/application.test.mjs +++ b/test/application.test.mjs @@ -65,6 +65,7 @@ t.describe('constructor()', function() { assert.strictEqual(app.config.clusterWaitOnCrash, 1 * 1000) assert.strictEqual(app.ctx.db, ctx.db) assert.strictEqual(app.ctx.app, app) + assert.strictEqual(app.ctx.config, app.config) assert.strictEqual(app.ctx.util, ctx.util) assert.strictEqual(app.ctx.sc.Util, Util) assert.strictEqual(app.ctx.sc.bunyan, bunyan)