// import Notifier from '../src/notify.js' import Notifier from '@uci-utils/notify' ;(async () => { const notify = await Notifier.create({ // one could read a file for these environment variables or hard code them here. services:{ pushsafer:{ module: '@uci-utils/notify-pushsafer-plugin', k: process.env.PS_API_KEY, d: process.env.PS_DEVICE_ID // device or group id }, email:{ module: '@uci-utils/notify-email-plugin', credentials: { user: process.env.GMAIL_SMTP_USER, pass:process.env.GMAIL_SMTP_PW }, to: process.env.NOTIFY_EMAIL_RECIPIENTS, subject:'uci notification' } } }) // console.log (notify._services.pushsafer._req) // notify.disableService('pushsafer') // notify.enableService('pushsafer') // console.log(await notify.send('a test message','pushsafer')) let res = await notify.send('simple message to all services') // let res = await notify.send({subject:'subject as message',text:'this details'}) // if (res.error) console.log('errors',res) // else console.log(res) // res = await notify.send({subject:'object message',otherprop:'some object in body'}) if (res.error) console.log('errors',res) // else console.log(res) })().catch(err => { console.log('FATAL: UNABLE TO START NOTIFER! \n',err) process.exitCode = 1 process.kill(process.pid, 'SIGINT') })