-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
21 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,48 @@ | ||
var config = require('snyk-config')(__dirname + '/../..'); | ||
import * as snykConfig from 'snyk-config'; | ||
import * as userConfig from './user-config'; | ||
import * as url from 'url'; | ||
|
||
var DEFAULT_TIMEOUT = 5 * 60; // in seconds | ||
const DEFAULT_TIMEOUT = 5 * 60; // in seconds | ||
interface Config { | ||
API: string; | ||
disableSuggestions: string; | ||
org: string; | ||
ROOT: string; | ||
timeout: number; | ||
PROJECT_NAME: string; | ||
} | ||
|
||
const config: Config = snykConfig(__dirname + '/../..'); | ||
|
||
// allow user config override of the api end point | ||
var endpoint = require('./user-config').get('endpoint'); | ||
const endpoint = userConfig.get('endpoint'); | ||
if (endpoint) { | ||
config.API = endpoint; | ||
} | ||
|
||
var disableSuggestions = require('./user-config').get('disableSuggestions'); | ||
const disableSuggestions = userConfig.get('disableSuggestions'); | ||
if (disableSuggestions) { | ||
config.disableSuggestions = disableSuggestions; | ||
} | ||
|
||
var org = require('./user-config').get('org'); | ||
const org = userConfig.get('org'); | ||
if (!config.org && org) { | ||
config.org = org; | ||
} | ||
|
||
// client request timeout | ||
// to change, set this config key to the desired value in seconds | ||
// invalid (non-numeric) value will fallback to the default | ||
var timeout = require('./user-config').get('timeout'); | ||
const timeout = userConfig.get('timeout'); | ||
if (!config.timeout) { | ||
config.timeout = +timeout ? +timeout : DEFAULT_TIMEOUT; | ||
} | ||
|
||
// this is a bit of an assumption that our web site origin is the same | ||
// as our API origin, but for now it's okay - RS 2015-10-16 | ||
if (!config.ROOT) { | ||
var url = require('url'); | ||
var apiUrl = url.parse(config.API); | ||
const apiUrl = url.parse(config.API); | ||
config.ROOT = apiUrl.protocol + '//' + apiUrl.host; | ||
} | ||
|
||
module.exports = config; | ||
export = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters