The server configuration is tailored from 2 configuration files, but the starting point is config/server/config.jsThis file will merge the configuration files inside the config/server/env folder. Inside this folder we will find 4 files, all.js configuration and 3 environment configuration, where all.js is going to be the base template for the final configuration.

Example all.js
const DOMAIN_NAME = 'localhost'
const SERVER_PORT = process.env.PORT || 3000

module.exports = {
    domain: DOMAIN_NAME,
    app: {
        title: 'Enterprise Search',
        description: 'Enterprise Search',
        keywords: 'Enterprise Search, Independent'
    },
    port: SERVER_PORT,
    logging: { . . . },
    esui: {
        baseUrl: `http://${DOMAIN_NAME}:4200`
    },
    security: { . . . },
    mailer: { . . .},
    analytics: {
        enable: true
    },
    chat_forum: {
        enable: false,
        history_size: 100
    },
    // ElasticSearch connection for permissions, and other features
    elastic: {
        schema: 'http',
        host: 'localhost',
        port: 9200,
        indexName: 'esui'
    }
}

The 3 environment configuration are just mirror images of the all.js, these configuration have specific values for different properties which will overwrite the ones in all.js. And as the name suggest each environment configuration contains different values for different environment, so far the Enterprise Search manages 3 environments local, development and production.



Selecting The Environment Configuration

As mention before the config/server/config.js manages the merging of the all.js with the environment configuration. 

To choose a configuration environment the enviroment variable NODE_ENV must be set, the server will look into this variable for the name of the configuration to use. By default if no environment is specified the one selected will be development.

Set Environment Variable  _

You can set this variable depending on the console, like this:

For Local

  • Powershell: $env:NODE_ENV="local"
  • CMD: set NODE_ENV="local"
  • Shell: export NODE_ENV="local"

For Development

  • Powershell: $env:NODE_ENV="development"
  • CMD: set NODE_ENV="development"
  • Shell: export NODE_ENV="development"

For Production

  • Powershell: $env:NODE_ENV="production"
  • CMD: set NODE_ENV="production"
  • Shell: export NODE_ENV="production"

This also means, more configuration enviroments can be added, as long as the nave in the environment variable matches with the configuration name, for examples if NODE_ENV value was test, then file name should be test.js

  • No labels