From 1d7b11822911a3ed0fdd97d7ff3f60ae86ef501e Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Thu, 10 Mar 2022 13:38:35 +0000 Subject: [PATCH] lib: Add optional port parameter that is prefilled. Prevents crashes if no port is specified package: Increment beta version --- core/lib.mjs | 6 +++++- package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/lib.mjs b/core/lib.mjs index 1f85acb..5625af3 100644 --- a/core/lib.mjs +++ b/core/lib.mjs @@ -6,7 +6,7 @@ import StaticProvider from './providers/static.mjs' import Core from './core.mjs' export default class ServiceCore { - constructor(name, root_import_meta_url, dbfilename = 'db.json') { + constructor(name, root_import_meta_url, port = 4000, dbfilename = 'db.json') { if (!root_import_meta_url) { throw new Error('ServiceCore must be called with the full string from "import.meta.url" from a file residing in the root directory') } @@ -19,6 +19,10 @@ export default class ServiceCore { this.db = null this.core = null this.app = null + + this.setConfig({ + port: port, + }) } setConfig(config) { diff --git a/package.json b/package.json index c0ded20..c263169 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "service-core", - "version": "3.0.0-beta.7", + "version": "3.0.0-beta.8", "description": "Core boiler plate code to install node server as windows service", "main": "index.mjs", "scripts": {