forked from nukeop/nuclear
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): add a config service working and Sentry support in prod
- Loading branch information
Chazz
committed
Dec 15, 2019
1 parent
c47d770
commit 0791984
Showing
17 changed files
with
116 additions
and
61 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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ACOUSTIC_ID_KEY=Fivodjxo37 | ||
# not used in development i put it here to not forget to add it in travis or whaterver CI we use | ||
SENTRY_DSN=https://2fb5587831994721a8b5f77bf6010679@sentry.io/1256142 |
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const MANDATORY_ENV = ['ACOUSTIC_ID_KEY']; | ||
|
||
class Config { | ||
constructor() { | ||
if (process.env.NODE_ENV === 'production') { | ||
MANDATORY_ENV.push('SENTRY_DSN'); | ||
} | ||
|
||
this._validateEnv(); | ||
|
||
/** @type {string} */ | ||
this.sentryDsn = process.env.SENTRY_DSN; | ||
/** @type {{ key: string, url: string }} */ | ||
this.acousticId = { | ||
key: process.env.ACOUSTIC_ID_KEY, | ||
url: 'https://api.acoustid.org/v2/lookup' | ||
}; | ||
/** @type {string} */ | ||
this.youtubeUrl = 'https://www.youtube.com/watch'; | ||
/** @type {string} */ | ||
this.title = 'Nuclear Music Player'; | ||
/** @type {string[]} */ | ||
this.supportedFormats = [ | ||
'aac', | ||
'flac', | ||
'm4a', | ||
'mp3', | ||
'ogg', | ||
'wav' | ||
]; | ||
} | ||
|
||
_validateEnv() { | ||
MANDATORY_ENV.forEach(ENV => { | ||
if (!process.env[ENV]) { | ||
throw new Error(`missing mandatory env variable ${ENV}`); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
export default 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
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
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
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,6 +1,11 @@ | ||
import * as Sentry from '@sentry/electron'; | ||
|
||
const logger = { | ||
log() {}, | ||
error() {} | ||
warn() {}, | ||
error(err) { | ||
Sentry.captureException(err); | ||
} | ||
}; | ||
|
||
export default logger; |
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
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
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
Oops, something went wrong.