reliable-plugin

0.1.9 • Public • Published

reliable-plugin

NPM version node version build status

reliable plugin for reliable-master.

Install

npm install reliable-plugin

Usage

app.views

app.views is a Map object.

app.get('/path/index', function *() {
  this.app.views.get('layout')
})

app.addPluginI18n

// index.js
app.get('/path/index', functino *() {
  const app = this.app
  const locale = app._options.locale
  app.addPluginI18n(locale, require(`./resources/i18n/${locale}`))
})
 
// resources/i18n/en-US.js
module.exports = {
  key: value
}

app.addEventListener

slave means reliable-save

support event:

  • lostSlave: when a slave disconnect
  • slaveOnline: slave online
  • taskEnd: a task end
  • taskFailed: task end and failed, but doesn't dispatch taskEnd event
app.addEventListener('lostSlave', data => {})
 
app.addEventListener('lostSlave', data => {
  
}, {
  isOnce: true, // only trigger once
  scope: null // the scope where the callback is defined
})

app.removeEventListener

const func = () => {}
 
app.addEventListener('lostSlave', func)
app.removeEventListener('lostSlave', func)
 
// ---------- or -------------
 
app.addEventListener('lostSlave', func, { id: 'xxx' })
app.removeEventListener('lostSlave', xxx)

app.registeCollection

registe a plugin collection

app.registeCollection({
  name: 'slack', // plugin name, should be unique
  url: '', // optional, auto add prefix `/plugin`
  data: {
    channel: []
  }
})

app.getDB

const pluginModel = app.getDB()
pluginModel
  .getDataByName('slack')
  .then(data => {
    conosle.log(data)
  })

app.getTaskDB

const taskModel = app.getTaskDB()
taskModel
  .getByProjectId('project id')
  .then(data => {
    conosle.log(data)
  })

app.configMail

const mail = app.configMail({
  locale: 'zh-CN',
  mail: {},
  site: {}
})
 
mail.sendTaskEndMail('your.email@address', data, info => {
  conosle.log(info)
})

more detail, see reliable-mail

Example

Readme

Keywords

Package Sidebar

Install

npm i reliable-plugin

Weekly Downloads

0

Version

0.1.9

License

MIT

Last publish

Collaborators

  • brunoyang