Skip to content

Commit 1256b22

Browse files
committed
refactoring config vars
1 parent ca41201 commit 1256b22

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

App/Config/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ This directory contains configuration variables in 3 files:
55

66
You need to create `index.js` by copying the right file.
77

8-
####Careful
8+
#### Warning
99
Each time you need to build, you need to verify if your `index.js` is the right one.
1010
For example, during development, before building your app do:
1111
```
1212
cp App\Config\index.dev.js App\Config\index.js
1313
```
14+
In other environment, you must pay attention to change your `index.js` with the good one.
15+
Also, make sure you add each configuration variable in each configuration file.
1416

15-
####Usage
17+
#### Usage
1618
```
17-
import config from 'App/Config'
19+
import Config from 'App/Config'
1820
1921
...
20-
let uri = config.API_URL
22+
let uri = Config.API_URL
2123
...
2224
2325
```

App/Config/index.dev.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const config = {
1+
export const Config = {
22
API_URL: 'https://query.yahooapis.com/v1/public/',
33
API_PREFIX: 'api',
44
}
5-
6-
export default config

App/Config/index.production.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const config = {
1+
export const Config = {
22
API_URL: 'https://query.yahooapis.com/v1/public/',
33
API_PREFIX: 'api',
44
}
5-
6-
export default config

App/Config/index.staging.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const config = {
1+
export const Config = {
22
API_URL: 'https://query.yahooapis.com/v1/public/',
33
API_PREFIX: 'api',
44
}
5-
6-
export default config

App/Service/WeatherService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { create } from 'apisauce'
2-
import config from 'App/Config'
2+
import { Config } from 'App/Config'
33

44
const weatherApiClient = create({
5-
baseURL: config.API_URL,
5+
baseURL: Config.API_URL,
66
headers: {
77
Accept: 'application/json',
88
'Content-Type': 'application/json',

0 commit comments

Comments
 (0)