/**
 * Docker environment settings
 */

module.exports = {

  models: {
    connection: 'postgresql',
    migrate: 'alter'
  },

  port: 80,

  log: {
    level: process.env['LOG_LEVEL']
  },

  auth: {
    static: {
      username: process.env['APP_USERNAME'],
      password: process.env['APP_PASSWORD']
    }
  },
  appUrl: process.env['APP_URL'],
  connections: {
    postgresql: {
      adapter: 'sails-postgresql',
      host: process.env['DB_HOST'] || process.env['DATABASE_URL'].split('@')[1].split(':')[0],
      port: process.env['DB_PORT'] || process.env['DATABASE_URL'].split('@')[1].split(':')[1].split('/')[0],
      user: process.env['DB_USERNAME'] || process.env['DATABASE_URL'].split('@')[0].split(':')[1].split('/')[2],
      password: process.env['DB_PASSWORD'] || process.env['DATABASE_URL'].split('@')[0].split(':')[2],
      database: process.env['DB_NAME'] || process.env['DATABASE_URL'].split('/')[3]
    }
  },
  jwt: {
    // Recommended: 63 random alpha-numeric characters
    // Generate using: https://www.grc.com/passwords.htm
    token_secret: process.env['TOKEN_SECRET'],
  },
  files: {
    dirname: process.env['ASSETS_PATH'] || '/tmp/',
  },
  session: {
    // Recommended: 63 random alpha-numeric characters
    // Generate using: https://www.grc.com/passwords.htm
    token_secret: process.env['TOKEN_SECRET'],
    database: process.env['DB_NAME'] || process.env['DATABASE_URL'].split('/')[3],
    host: process.env['DB_HOST'] || process.env['DATABASE_URL'].split('@')[1].split(':')[0],
    user: process.env['DB_USERNAME'] || process.env['DATABASE_URL'].split('@')[0].split(':')[1].split('/')[2],
    password: process.env['DB_PASSWORD'] || process.env['DATABASE_URL'].split('@')[0].split(':')[2],
    port: process.env['DB_PORT'] || process.env['DATABASE_URL'].split('@')[1].split(':')[1].split('/')[0]
  }

};

@@ -443,32 +443,63 @@
 nv%5B'DB_HOST'%5D %7C%7C
+ process.env%5B'DATABASE_URL'%5D &&
  process.env%5B'DA
@@ -569,32 +569,63 @@
 nv%5B'DB_PORT'%5D %7C%7C
+ process.env%5B'DATABASE_URL'%5D &&
  process.env%5B'DA
@@ -713,32 +713,63 @@
 DB_USERNAME'%5D %7C%7C
+ process.env%5B'DATABASE_URL'%5D &&
  process.env%5B'DA
@@ -861,32 +861,63 @@
 DB_PASSWORD'%5D %7C%7C
+ process.env%5B'DATABASE_URL'%5D &&
  process.env%5B'DA
@@ -991,32 +991,63 @@
 nv%5B'DB_NAME'%5D %7C%7C
+ process.env%5B'DATABASE_URL'%5D &&
  process.env%5B'DA
@@ -1528,32 +1528,63 @@
 nv%5B'DB_NAME'%5D %7C%7C
+ process.env%5B'DATABASE_URL'%5D &&
  process.env%5B'DA
@@ -1638,32 +1638,63 @@
 nv%5B'DB_HOST'%5D %7C%7C
+ process.env%5B'DATABASE_URL'%5D &&
  process.env%5B'DA
@@ -1766,32 +1766,63 @@
 DB_USERNAME'%5D %7C%7C
+ process.env%5B'DATABASE_URL'%5D &&
  process.env%5B'DA
@@ -1912,32 +1912,63 @@
 DB_PASSWORD'%5D %7C%7C
+ process.env%5B'DATABASE_URL'%5D &&
  process.env%5B'DA
@@ -2036,32 +2036,63 @@
 nv%5B'DB_PORT'%5D %7C%7C
+ process.env%5B'DATABASE_URL'%5D &&
  process.env%5B'DA

Check for DATABASE_URL before splitting it (#209)