Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 769 Bytes

03_configuration.md

File metadata and controls

29 lines (21 loc) · 769 Bytes

3 - Configuration

Configuration (credentials, database connection string, ...) should be stored in the environment.

What does that mean for our application ?

In config/connections.js, we define the mongo connection and use MONGO_URL environment variable to pass the mongo connection string.

module.exports.connections = {
  mongo: {
    adapter: 'sails-mongo',
    url: process.env.MONGO_URL
  }
};

In config/model.js, we make sure the mongo connection defined above is the one used.

module.exports.models = {
  connection: 'mongo',
  migrate: 'safe'
};

Those changes enable to provide a different MONGO_URL very easily as it's defined in the environment.

Previous - Next