How to configure various environments and related configurations in the sails.js section?

I am running the RoR 2010 application for Sails.js. On his part, Sails.js looks like the best infrastructure for porting an application to the Node.js platform. In the process, I came across a limitation - it seems that the sails are focused only on the development environment through local.js and the production environment.

In RoR, I had an environment folder in config, which contained the developer, test, intermediate, production, etc. files containing the constants, logging levels, etc., specific to this environment. I am looking for an example of the same structure under Sails.js.

Thanks,

_K

+1
source share
1

SailsJS , local.js , .

, , , process.env.NODE_ENV . , adapters.js:

var production = {
  'default': 'mongo',
  mongo: {
    module: 'sails-mongo',
    url: "mongodb://[user]:[password]@[host]:[port]/[db-name]",
    schema: true
  }
};

var staging = {
  'default': 'mongo',
  mongo: {
    module: 'sails-mongo',
    url: "mongodb://[user]:[password]@[host]:[port]/[db-name]",
    schema: true
  }
};

var development = {
  'default': 'disk',
  disk: {
    module: 'sails-disk'
  }
};

var setAdapter = function() {
  var env = process.env.NODE_ENV;

  if (env === 'production') {
    return production;
  } else if (env === 'staging') {
    return staging;
  } else {
    return development;
  }
};

var adapters = setAdapter();

module.exports.adapters = adapters;

, NODE_ENV , .

0

Source: https://habr.com/ru/post/1523938/


All Articles