1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/lib/options.js

35 lines
996 B
JavaScript
Raw Normal View History

'use strict';
2016-12-04 14:09:37 +01:00
2016-12-02 16:34:05 +01:00
const { publicFolder } = require('unleash-frontend');
const isDev = () => process.env.NODE_ENV === 'development';
const DEFAULT_OPTIONS = {
2016-12-03 13:45:22 +01:00
databaseUrl: process.env.DATABASE_URL,
port: process.env.HTTP_PORT || process.env.PORT || 4242,
baseUriPath: process.env.BASE_URI_PATH || '',
serverMetrics: true,
enableLegacyRoutes: true,
2016-12-02 16:34:05 +01:00
publicFolder,
2016-12-04 14:09:37 +01:00
enableRequestLogger: isDev(),
};
module.exports = {
2017-06-28 10:17:14 +02:00
createOptions: opts => {
2016-12-27 21:03:50 +01:00
const options = Object.assign({}, DEFAULT_OPTIONS, opts);
2016-12-01 00:42:14 +01:00
// If we are running in development we should assume local db
2016-12-04 14:09:37 +01:00
if (isDev() && !options.databaseUrl) {
2017-06-28 10:17:14 +02:00
options.databaseUrl =
'postgres://unleash_user:passord@localhost:5432/unleash';
2016-12-01 00:42:14 +01:00
}
2016-12-03 13:45:22 +01:00
if (!options.databaseUrl) {
2017-06-28 10:17:14 +02:00
throw new Error(
'You must either pass databaseUrl option or set environemnt variable DATABASE_URL'
);
}
return options;
2016-12-04 14:09:37 +01:00
},
};