Skip to content

Commit ca41201

Browse files
committed
refactoring config vars
1 parent 40e7a77 commit ca41201

File tree

7 files changed

+17
-29
lines changed

7 files changed

+17
-29
lines changed

App/Config/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index.js

App/Config/README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
This directory contains config with environment variables.
2-
The directory ``environment`` contains 3 files :
3-
- ``dev.config`` : contains development environment variables
4-
- ``production.config`` : contains production environment variables
5-
- ``staging.config`` : contains beta tests environment variables
1+
This directory contains configuration variables in 3 files:
2+
- `index.dev.js` : contains development variables
3+
- `index.production.js` : contains production variables
4+
- `index.staging.js` : contains beta tests variables
5+
6+
You need to create `index.js` by copying the right file.
7+
8+
####Careful
9+
Each time you need to build, you need to verify if your `index.js` is the right one.
10+
For example, during development, before building your app do:
11+
```
12+
cp App\Config\index.dev.js App\Config\index.js
13+
```
614

715
####Usage
816
```
9-
import config from 'App/Config/config'
17+
import config from 'App/Config'
1018
1119
...
1220
let uri = config.API_URL
1321
...
22+
1423
```

App/Config/environment/dev.config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

App/Config/environment/staging.config.js renamed to App/Config/index.dev.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
const config = {
2-
APP_ID: 'com.tcm.boilerplate',
3-
APP_ENV: 'staging',
4-
APP_VERSION: '0.1.0',
5-
APP_BUILD: '1',
62
API_URL: 'https://query.yahooapis.com/v1/public/',
73
API_PREFIX: 'api',
84
}

App/Config/environment/production.config.js renamed to App/Config/index.production.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
const config = {
2-
APP_ID: 'com.tcm.boilerplate',
3-
APP_ENV: 'production',
4-
APP_VERSION: '0.1.0',
5-
APP_BUILD: '1',
62
API_URL: 'https://query.yahooapis.com/v1/public/',
73
API_PREFIX: 'api',
84
}

App/Config/config.js renamed to App/Config/index.staging.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
const config = {
2-
APP_ID: 'com.tcm.boilerplate',
3-
APP_ENV: 'development',
4-
APP_VERSION: '0.1.0',
5-
APP_BUILD: '1',
62
API_URL: 'https://query.yahooapis.com/v1/public/',
73
API_PREFIX: 'api',
84
}

App/Service/WeatherService.js

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

44
const weatherApiClient = create({
55
baseURL: config.API_URL,

0 commit comments

Comments
 (0)