1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00
unleash.unleash/lib/options.js
ivaosthu de55bbc9ef Option to disable request logging.
Because all request details are available via
prometheus there is no need to also log all requests.

This solves #164 but we should still replace log4j with something else.
2016-12-03 14:09:09 +01:00

29 lines
932 B
JavaScript

'use strict';
const { publicFolder } = require('unleash-frontend');
const isDev = () => process.env.NODE_ENV === 'development';
const DEFAULT_OPTIONS = {
databaseUrl: process.env.DATABASE_URL,
port: process.env.HTTP_PORT || process.env.PORT || 4242,
baseUriPath: process.env.BASE_URI_PATH || '',
serverMetrics: true,
publicFolder,
enableRequestLogger: isDev() ? true : false
};
module.exports = {
createOptions: (opts) => {
const options = Object.assign({}, DEFAULT_OPTIONS, opts);
// If we are running in development we should assume local db
if(isDev() && !options.databaseUrl) {
options.databaseUrl = 'postgres://unleash_user:passord@localhost:5432/unleash';
}
if (!options.databaseUrl) {
throw new Error('You must either pass databaseUrl option or set environemnt variable DATABASE_URL');
}
return options;
}
}