Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

hm496/egg-apollo-plus

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

egg-apollo-plus

ctrip-apollo plugin for egg.

Install

$ npm i egg-apollo-plus

Configuration

egg-apollo-plus support all configurations in ctrip-apollo. and with default configurations below:

  • cachePath: path.join(appInfo.baseDir, 'apollo_cache')
  • host: 'http://localhost:8070'

egg-apollo-plus provides more options:

  • namespaces: ['application']
  • parseConfig: true parse json config
// {app_root}/config/config.default.js
exports.apollo = {
  // host: 'http://localhost:8070',
};

Usage

In controller, you can use app.apollo.getConfigAll and app.apollo.getConfig to get config.

// app/controller/home.js

module.exports = app => {
  return class HomeController extends app.Controller {
    async index() {
      const { ctx, app } = this;
      // get all config
      const allConfig = await app.apollo.getConfigAll();
      // get config by key
      const someConfig = await app.apollo.getConfig('some key');
      ctx.body = 'config';
    }
  };
};

Questions & Suggestions

Please open an issue here.

License

MIT

About

ctrip-apollo plugin for egg

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.