Skip to content

Latest commit

 

History

History
67 lines (54 loc) · 1.51 KB

README.md

File metadata and controls

67 lines (54 loc) · 1.51 KB

Build Status Coverage

egg-singletons

Egg plugin to define multiple singletons in a convenient way.

Install

$ npm install egg-singletons

Configurations

config/plugin.js

exports.singletons = {
  enable: true,
  package: 'egg-singletons'
}

config/config.default.js

exports.singletons = {
  foo: {
    // Load into app, default is open
    app: true,
    // Load into agent, default is close
    agent: false,
    create: (config, app) => {
      return a => {
        console.log(a)
      }
    }
  }
}

Then:

...
  async doSomething () {
    this.app.foo('hello')
  }
...

License

MIT