Version 1.0.2

This commit is contained in:
Jonatan Nilsson 2020-09-09 13:54:26 +00:00
parent f32730e0a3
commit 0ad204c8f9
8 changed files with 30 additions and 1028 deletions

1
.gitignore vendored
View file

@ -104,3 +104,4 @@ dist
.tern-port
*.zip
db.json

1
.npmrc Normal file
View file

@ -0,0 +1 @@
package-lock=false

View file

@ -1,20 +1,19 @@
import http from 'http'
import path from 'path'
import { readFileSync } from 'fs'
import { fileURLToPath } from 'url'
export function run(config, db, log, core) {
export function run(config, db, log, core, http) {
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const staticPackage = path.join(__dirname,'../package.json')
config = JSON.parse(readFileSync(staticPackage))
let packageInfo = JSON.parse(readFileSync(staticPackage))
const server = http.createServer(function (req, res) {
res.writeHead(200);
res.write(JSON.stringify(config, null, ' '))
res.write(JSON.stringify(packageInfo, null, ' '))
res.end()
})
let port = config.managePort || 4000
let port = config.port || 4000
server.listen(port, '0.0.0.0', function(err) {
if (err) {

9
config.json Normal file
View file

@ -0,0 +1,9 @@
{
"name": "service-core-helloworld",
"serviceName": "Service-Core HelloWorld App",
"description": "Simple Hello world app for service core",
"port": 4270,
"managePort": 4269,
"appRepository": null,
"manageRepository": null
}

View file

@ -1,5 +1,5 @@
export function start(config, db, log, core) {
export function start(config, db, log, core, http) {
return import('./api/server.mjs').then(function(module) {
return module.run(config, db, log, core)
return module.run(config, db, log, core, http)
})
}

1003
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,10 @@
{
"name": "sc-helloworld",
"version": "1.0.1",
"version": "1.0.2",
"description": "Hello World app for service core",
"main": "index.js",
"scripts": {
"dev": "nodemon --watch api --watch runner.mjs --watch index.mjs runner.mjs",
"dev": "nodemon --watch api --watch runner.mjs --watch index.mjs runner.mjs | bunyan",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
@ -21,6 +21,7 @@
"node-static": "^0.7.11"
},
"devDependencies": {
"bunyan-lite": "^1.0.1",
"nodemon": "^2.0.4"
}
}

View file

@ -1,16 +1,10 @@
import('./index.mjs').then(function(module) {
return module.start({}, {}, {
debug: console.log.bind(console),
info: console.log.bind(console),
warn: console.log.bind(console),
error: console.error.bind(console),
fatal: console.error.bind(console),
event: {
debug: function() {},
info: function() {},
warn: function() {},
error: function() {},
fatal: function() {},
}
}, {})
})
import ServiceCore from 'service-core'
import * as server from './index.mjs'
const serviceCore = new ServiceCore('sc-manager', import.meta.url)
serviceCore.init(server)
.then(function() {})
.catch(function(err) {
serviceCore.log.error(err, 'Unknown error starting server')
})