Skip to content

Commit

Permalink
Remove cruft from server settings
Browse files Browse the repository at this point in the history
  • Loading branch information
villetou committed Feb 10, 2016
1 parent 43a338b commit d64b32e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 39 deletions.
28 changes: 7 additions & 21 deletions dev_server/getSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@ import {Provider} from 'nconf'
import _ from 'lodash'

const defaults = {
serverUrl: 'http://localhost:8080',
apiBaseUrl: 'http://localhost:8000',
publicUrl: 'http://localhost:8080',
serverUrl: process.env.SERVER_URL || 'http://localhost:8080',
apiBaseUrl: process.env.API_BASE_URL || 'http://localhost:8000',
publicUrl: process.env.PUBLIC_URL || 'http://localhost:8080',
helsinkiAuthId: process.env.CLIENT_ID || 'this-is-mock',
helsinkiAuthSecret: process.env.CLIENT_SECRET || 'this-is-mock',
helsinkiTargetApp: process.env.TARGET_APP || 'linkedevents-ui',
jwtAudience: 'linkedevents-ui',
jwtKey: null,
sessionSecret: null,
dev: true,
serverRendering: false,
cold: false,
bundleSrc: null, // Usually generated by the boot-time compilation process
};
sessionSecret: process.env.SESSION_SECRET || (Math.random()).toString(),
dev: true
}

const requiredKeys = ["helsinkiAuthId", "helsinkiAuthSecret", "jwtKey", "sessionSecret"]
const requiredKeys = ["helsinkiAuthId", "helsinkiAuthSecret", "helsinkiTargetApp"]

export default function getOptions() {
// Check configs
Expand All @@ -33,15 +28,6 @@ export default function getOptions() {
settings.port = port
settings.publicUrl = settings.publicUrl || settings.serverUrl

if (settings.dev) {
if (!settings.sessionSecret) {
settings.sessionSecret = 'Don\'t Panic.'
}
if (!settings.jwtKey) {
settings.jwtKey = 'linkedevents-ui'
}
}

const missingKeys = requiredKeys.filter((key) => !settings[key])
if (missingKeys.length) {
throw new Error("These configuration values are required but are currently missing: " + missingKeys.join(", "))
Expand Down
22 changes: 4 additions & 18 deletions server/getSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@ const defaults = {
helsinkiAuthId: process.env.CLIENT_ID || 'this-is-mock',
helsinkiAuthSecret: process.env.CLIENT_SECRET || 'this-is-mock',
helsinkiTargetApp: process.env.TARGET_APP || 'linkedevents-ui',
jwtAudience: 'linkedevents-ui',
jwtKey: null,
sessionSecret: null,
dev: false,
serverRendering: false,
cold: false,
bundleSrc: null, // Usually generated by the boot-time compilation process
};
sessionSecret: process.env.SESSION_SECRET || (Math.random()).toString(),
dev: false
}

const requiredKeys = ["helsinkiAuthId", "helsinkiAuthSecret", "jwtKey", "sessionSecret"]
const requiredKeys = ["helsinkiAuthId", "helsinkiAuthSecret", "helsinkiTargetApp"]

export default function getOptions() {
// Check configs
Expand All @@ -33,15 +28,6 @@ export default function getOptions() {
settings.port = port
settings.publicUrl = settings.publicUrl || settings.serverUrl

if (settings.dev) {
if (!settings.sessionSecret) {
settings.sessionSecret = 'Don\'t Panic.'
}
if (!settings.jwtKey) {
settings.jwtKey = 'linkedevents-ui'
}
}

const missingKeys = requiredKeys.filter((key) => !settings[key])
if (missingKeys.length) {
throw new Error("These configuration values are required but are currently missing: " + missingKeys.join(", "))
Expand Down

0 comments on commit d64b32e

Please sign in to comment.