lib: Now generates a valid config and enforces provider on lib to be static
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded

This commit is contained in:
Jonatan Nilsson 2022-03-27 16:02:53 +00:00
parent 95d72fc404
commit 99d7a0655d
3 changed files with 17 additions and 2 deletions

View file

@ -15,7 +15,10 @@ export default class ServiceCore {
this.dbfilename = dbfilename
this.log = getLog(name)
this.name = name
this.config = {}
this.config = {
name: name,
title: 'Development Version of ' + name,
}
this.db = null
this.core = null
this.app = null
@ -26,6 +29,9 @@ export default class ServiceCore {
}
setConfig(config) {
if (!config.provider) {
config.provider = 'static'
}
this.config[this.name] = config
}
@ -41,6 +47,9 @@ export default class ServiceCore {
core: this.core,
}, provider, this.name)
this.app.registerModule(module)
this.core.applications.push(this.app)
this.core.applicationMap.set(this.name, this.app)
}
run() {

View file

@ -1,6 +1,6 @@
{
"name": "service-core",
"version": "3.0.0-beta.10",
"version": "3.0.0-beta.11",
"description": "Core boiler plate code to install node server as windows service",
"main": "index.mjs",
"scripts": {

View file

@ -26,6 +26,10 @@ t.describe('', function() {
let core = new sc.ServiceCore(assertAppName, import.meta.url)
await core.init(module)
assert.strictEqual(core.core.applications.length, 1)
assert.strictEqual(core.core.applications[0], core.app)
assert.strictEqual(core.core.applicationMap.size, 1)
assert.strictEqual(core.core.applicationMap.get(assertAppName), core.app)
assert.strictEqual(core.app.name, assertAppName)
assert.strictEqual(core.app.module, module)
})
@ -73,6 +77,8 @@ t.describe('', function() {
let err = await assert.isRejected(core.run())
assert.strictEqual(err, assertError)
assert.strictEqual(core.config['testapp'].port, assertPort)
assert.strictEqual(core.config['testapp'].provider, 'static')
assert.strictEqual(module.start.firstCall[0], core.app.http)
assert.strictEqual(module.start.firstCall[1], assertPort)
assert.strictEqual(module.start.firstCall[2], core.app.ctx)