lib: Add optional port parameter that is prefilled. Prevents crashes if no port is specified
Some checks failed
continuous-integration/appveyor/branch AppVeyor build failed

package: Increment beta version
This commit is contained in:
Jonatan Nilsson 2022-03-10 13:38:35 +00:00
parent 1f70f36e8d
commit 1d7b118229
2 changed files with 6 additions and 2 deletions

View file

@ -6,7 +6,7 @@ import StaticProvider from './providers/static.mjs'
import Core from './core.mjs' import Core from './core.mjs'
export default class ServiceCore { 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) { 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') 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.db = null
this.core = null this.core = null
this.app = null this.app = null
this.setConfig({
port: port,
})
} }
setConfig(config) { setConfig(config) {

View file

@ -1,6 +1,6 @@
{ {
"name": "service-core", "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", "description": "Core boiler plate code to install node server as windows service",
"main": "index.mjs", "main": "index.mjs",
"scripts": { "scripts": {