-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: detailed error messages leak into production responses (#713)
* fix: detailed error messages leak into production responses * fix: typo in env util
- Loading branch information
1 parent
2327c13
commit 0f406b5
Showing
5 changed files
with
52 additions
and
1 deletion.
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
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,7 @@ | ||
/* @flow */ | ||
|
||
const isEnv = value => () => process.env.NODE_ENV === value; | ||
|
||
export const isDevelopment: () => boolean = isEnv('development'); | ||
export const isProduction: () => boolean = isEnv('production'); | ||
export const isTest: () => boolean = isEnv('test'); |
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,25 @@ | ||
/* @flow */ | ||
|
||
import { expect } from 'chai'; | ||
import { afterEach, test } from 'mocha'; | ||
|
||
import * as env from '../env'; | ||
import setEnv from '../../../test/utils/set-env'; | ||
|
||
afterEach(() => { | ||
setEnv('test'); | ||
}); | ||
|
||
test('isDevelopment()', () => { | ||
setEnv('development'); | ||
expect(env.isDevelopment()).to.be.true; | ||
}); | ||
|
||
test('isProduction()', () => { | ||
setEnv('production'); | ||
expect(env.isProduction()).to.be.true; | ||
}); | ||
|
||
test('isTest()', () => { | ||
expect(env.isTest()).to.be.true; | ||
}); |
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,9 @@ | ||
/* @flow */ | ||
|
||
type Environment = 'development' | ||
| 'production' | ||
| 'test'; | ||
|
||
export default function setEnv(value: Environment): void { | ||
global.process.env.NODE_ENV = value; | ||
} |