Skip to content

Commit c182458

Browse files
author
Robert S
committed
create Environment type
1 parent 1cb905e commit c182458

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

src/environments/base.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* Base is the default environment for production.
33
* Add everything here and override value in other files if needed.
4+
* https://blog.usejournal.com/my-awesome-custom-react-environment-variables-setup-8ebb0797d8ac
45
*/
5-
6-
export default function(baseApi) {
6+
export default function baseEnv(baseApi) {
77
return {
88
route: {
99
baseRoute: '',
@@ -16,5 +16,6 @@ export default function(baseApi) {
1616
},
1717
isProduction: true,
1818
isDevelopment: false,
19+
isTesting: false,
1920
};
2021
}

src/environments/development.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import environment from './base';
33
const baseApi = 'https://api.tvmaze.com';
44
const env = environment(baseApi);
55

6-
export default {
6+
const developmentEnv = {
77
...env,
88
// override anything that gets added from base.
99
api: {
@@ -14,3 +14,5 @@ export default {
1414
isProduction: false,
1515
isDevelopment: true,
1616
};
17+
18+
export default developmentEnv;

src/environments/production.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import environment from './base';
88
const baseApi = 'https://api.tvmaze.com';
99
const env = environment(baseApi);
1010

11-
export default {
11+
const productionEnv = {
1212
...env,
1313
route: {
1414
...env.route,
1515
baseRoute: '/react-redux-architecture', // Fixes issue with Github Pages
1616
},
1717
};
18+
19+
export default productionEnv;

src/environments/test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import environment from './base';
33
const baseApi = 'https://api.tvmaze.com';
44
const env = environment(baseApi);
55

6-
export default {
6+
const testEnv = {
77
...env,
88
// override anything that gets added from base.
99
isProduction: false,
1010
isDevelopment: true,
1111
isTesting: true,
1212
};
13+
14+
export default testEnv;

src/typings.d.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,8 @@ declare module 'redux-freeze';
22
declare module 'lodash.groupby';
33

44
declare module 'environment' {
5-
const value: {
6-
route: {
7-
baseRoute: string;
8-
};
9-
api: {
10-
shows: string;
11-
episodes: string;
12-
cast: string;
13-
errorExample: string;
14-
};
15-
isDevelopment: boolean;
16-
isProduction: boolean;
17-
isTesting?: boolean;
18-
};
5+
import baseEnv from './environments/base';
6+
const value: ReturnType<typeof baseEnv>;
197

208
export default value;
219
}

0 commit comments

Comments
 (0)