File tree Expand file tree Collapse file tree 2 files changed +5
-13
lines changed Expand file tree Collapse file tree 2 files changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -4,19 +4,11 @@ import { NODE_ENVIRONMENT } from './env.validation';
4
4
5
5
export const getNodeEnv = ( ( ) => {
6
6
const env = process . env . NODE_ENV ;
7
-
8
- switch ( env ) {
9
- case 'test' :
10
- return NODE_ENVIRONMENT . test ;
11
- case 'development' :
12
- return NODE_ENVIRONMENT . development ;
13
- case 'stage' :
14
- return NODE_ENVIRONMENT . stage ;
15
- case 'production' :
16
- return NODE_ENVIRONMENT . production ;
17
- default :
18
- throw new InternalServerErrorException ( 'Unknown NODE_ENV' ) ;
7
+ const nodeEnv = NODE_ENVIRONMENT [ env ] ;
8
+ if ( nodeEnv === undefined ) {
9
+ throw new InternalServerErrorException ( 'Unknown NODE_ENV' ) ;
19
10
}
11
+ return nodeEnv ;
20
12
} ) ( ) ;
21
13
22
14
export const isIgnoreEnvFile =
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export const NODE_ENVIRONMENT = {
18
18
[ stage ] : stage ,
19
19
[ production ] : production ,
20
20
[ test ] : test ,
21
- } ;
21
+ } as const ;
22
22
23
23
export class EnvironmentVariables {
24
24
@IsEnum ( NODE_ENVIRONMENT )
You can’t perform that action at this time.
0 commit comments