File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11const apostrophe = require ( 'apostrophe' ) ;
22require ( 'dotenv' ) . config ( { path : '../.env' } ) ;
3- const { getEnv, getOptionalEnv } = require ( './utils/env' ) ;
3+ const { getEnv } = require ( './utils/env' ) ;
44
55function createAposConfig ( ) {
6- const redisUri = getOptionalEnv ( ' REDIS_URI' ) ;
6+ const redisUri = process . env . REDIS_URI ;
77
88 const sessionConfig = {
99 secret : getEnv ( 'SESSION_SECRET' ) ,
Original file line number Diff line number Diff line change @@ -7,15 +7,6 @@ const getEnv = (name) => {
77 return value ;
88} ;
99
10- const getOptionalEnv = ( name , defaultValue ) => {
11- const value = process . env [ name ] ;
12- if ( value === undefined ) {
13- return defaultValue ;
14- }
15- return value ;
16- } ;
17-
1810module . exports = {
1911 getEnv,
20- getOptionalEnv,
2112} ;
Original file line number Diff line number Diff line change 1- const { getEnv, getOptionalEnv } = require ( './env' ) ;
1+ const { getEnv } = require ( './env' ) ;
22
33describe ( 'getEnv utility' , ( ) => {
44 const OLD_ENV = process . env ;
@@ -30,30 +30,3 @@ describe('getEnv utility', () => {
3030 } ) . toThrow ( 'Environment variable "NON_EXISTENT_VAR" is not defined' ) ;
3131 } ) ;
3232} ) ;
33-
34- describe ( 'getOptionalEnv utility' , ( ) => {
35- const OLD_ENV = process . env ;
36-
37- beforeEach ( ( ) => {
38- jest . resetModules ( ) ;
39- process . env = { ...OLD_ENV } ;
40- } ) ;
41-
42- afterAll ( ( ) => {
43- process . env = OLD_ENV ;
44- } ) ;
45-
46- test ( 'should return environment variable value when it exists' , ( ) => {
47- process . env . OPTIONAL_TEST_VAR = 'optional-test-value' ;
48-
49- const result = getOptionalEnv ( 'OPTIONAL_TEST_VAR' ) ;
50-
51- expect ( result ) . toBe ( 'optional-test-value' ) ;
52- } ) ;
53-
54- test ( 'should return default value when environment variable does not exist' , ( ) => {
55- const result = getOptionalEnv ( 'NON_EXISTENT_OPTIONAL_VAR' , 'default' ) ;
56-
57- expect ( result ) . toBe ( 'default' ) ;
58- } ) ;
59- } ) ;
You can’t perform that action at this time.
0 commit comments