EggJS provides the feature of configuration at project level. EggBornJS extends the feature provided by EggJS, realizing the configuration at the module level

  1. Module can specify its own configuration
  2. The configuration at project level can override the one at module level

Definition of Config


module.exports = appInfo => {
  const config = {};

  config.message = 'Hello World';

  return config;

Usage of Config

Same Module


async echo2() {
  const message = this.ctx.config.message;

Across Module

async echo2() {
  const message = this.ctx.config.module('test-party').message;
Name Description
config.module(moduleName) get the config of the specified module

Override Config

Use project level config to override module level config, thereby changing Hello World to Hello World!


// modules
config.modules = {
  'test-party': {
    message: 'Hello World!',

Because EggJS can specify config separately for test environment, development environment and production environment, we can also customize the config of modules for different environments