nfp_sites/nfp_moe/index.mjs

39 lines
836 B
JavaScript
Raw Normal View History

import fs from 'fs'
import { pathToFileURL } from 'url'
2022-08-18 10:58:53 +00:00
import config from './base/config.mjs'
2022-04-05 14:43:23 +00:00
export function start(http, port, ctx) {
config.sources[1].store = ctx.config
2022-04-05 16:47:24 +00:00
return import('./api/server.mjs')
.then(function(module) {
let server = new module.default(http, port, ctx)
return server.run()
2022-04-05 16:47:24 +00:00
})
2022-04-05 14:43:23 +00:00
}
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
import('service-core').then(core => {
const port = 4030
var core = new core.ServiceCore('nfp_moe', import.meta.url, port, '')
let config = {
frontend: {
url: 'http://localhost:' + port
}
}
try {
config = JSON.parse(fs.readFileSync('./config.json'))
} catch {}
config.port = port
core.setConfig(config)
core.init({ start }).then(function() {
return core.run()
})
})
}