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/app/services/routines.service.js

31 lines
903 B

const { Service } = require('flitter-di')
const Routine = require('../classes/routine/Routine')
/*
* routines Service
* -------------------------------------------------------------
* This is a service file that will be made available through Flitter's
* dependency injector to the rest of the application based on its given
* canonical name.
*
* e.g. app.di().service("routines")
*/
class RoutinesService extends Service {
static get services() {
return [...super.services, 'app', 'configs', 'hosts']
}
async get(name) {
this.app.make(Routine)
const config = this.configs.get(`routines:${name}`)
const hosts = {}
for ( const host_name of config.hosts ) {
hosts[host_name] = await this.hosts.get(host_name)
}
return new Routine(hosts, config, config.type)
}
}
module.exports = exports = RoutinesService