0.1.9 • Published 8 years ago

reliable-plugin v0.1.9

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

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

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago