53 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-01-05 15:17:59 +01:00
'use strict';
module.exports = scope => {
2019-01-27 16:55:55 +01:00
// Production/Staging Template
if (['production', 'staging'].includes(scope.keyPath.split('/')[2])) {
// All available settings (bookshelf and mongoose)
const settingsBase = {
client: scope.client.database,
2019-01-28 15:47:38 +01:00
host: '${process.env.DATABASE_HOST || \'127.0.0.1\' }',
2019-01-27 16:55:55 +01:00
port: '${process.env.DATABASE_PORT || 27017 }',
srv: '${process.env.DATABASE_SRV || false }',
2019-01-31 14:40:55 +01:00
database: '${process.env.DATABASE_NAME || \'strapi\' }',
2019-01-27 16:55:55 +01:00
username: '${process.env.DATABASE_USERNAME || \'\' }',
password: '${process.env.DATABASE_PASSWORD || \'\' }',
ssl: '${process.env.DATABASE_SSL || false }'
};
// Apply only settings set during the configuration
2019-01-28 12:05:41 +01:00
Object.keys(scope.database.settings).forEach((key) => {
scope.database.settings[key] = settingsBase[key];
});
2019-01-27 16:55:55 +01:00
// All available options (bookshelf and mongoose)
const optionsBase = {
ssl: '${process.env.DATABASE_SSL || false }',
authenticationDatabase: '${process.env.DATABASE_AUTHENTICATION_DATABASE || \'\' }'
};
// Apply only options set during the configuration
2019-01-28 12:05:41 +01:00
Object.keys(scope.database.options).forEach((key) => {
scope.database.options[key] = optionsBase[key];
});
2019-01-27 16:55:55 +01:00
return {
defaultConnection: 'default',
connections: {
default: {
connector: scope.client.connector,
2019-01-28 12:05:41 +01:00
settings: scope.database.settings,
options: scope.database.options
2019-01-27 16:55:55 +01:00
}
}
};
}
2018-01-05 15:17:59 +01:00
return {
defaultConnection: 'default',
connections: {
default: scope.database
}
};
};