import { ConnectionManager, ScenarioEngine } from '@things-factory/integration-base'

export * from './migrations'
export * from './middlewares'
export * from './subscribers'
export * from './service'

import './routes'

process.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {
  console.log('%%%%%%%%%%%%%%%% SCENARIO ENGINE - BEGIN %%%%%%%%%%%%%%%%')
  try {
    await ConnectionManager.ready()
    await ScenarioEngine.loadAll()
  } catch (ex) {
    ConnectionManager.logger.error(ex)
  }
  console.log('%%%%%%%%%%%%%%%% SCENARIO ENGINE - END %%%%%%%%%%%%%%%%')
})
