You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
maestro/api.js

44 lines
1.2 KiB

const units = require('./Units.flitter')
delete units.App
const FlitterApp = require('libflitter/app/FlitterApp')
const app = new FlitterApp(units)
app.output.level = -Infinity
const services = app.di().container.proxy()
let ready = false
let ready_ps = []
app.up().then(() => {
ready = true
ready_ps.forEach(x => x(exports))
})
module.exports = exports = {
app,
services,
UniversalPath: require('./app/classes/logical/UniversalPath'),
ready: () => ready,
ready$: async () => {
if ( !ready )
return new Promise(res => ready_ps.push(res))
},
host(name_or_config) {
if ( typeof name_or_config === 'object' ) {
if ( !name_or_config.name )
throw new TypeError('Missing required host property: name')
if ( services.configs.canonical_items.hosts[name_or_config.name] )
throw new TypeError(`A host with the name ${name_or_config.name} is already registered.`)
services.configs.canonical_items.hosts[name_or_config.name] = name_or_config
return services.hosts.get(name_or_config.name)
}
return services.hosts.get(name_or_config)
},
}
exports.ready$().then(() => {
app.di().inject(exports.UniversalPath)
})