Skip to content

Commit c01f316

Browse files
authored
Explains config (#94)
[ci skip]
1 parent a999375 commit c01f316

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

README.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,41 @@ npm i --progress=false
5858

5959
### Project Structure
6060

61-
Source lives in `src/`. Compiled output goes in `dist/`.
61+
Source lives in `src/`. Compiled output goes in `dist/`. Configuration goes in
62+
`config/`.
6263

6364
#### Source Files
6465

6566
- `containers/`: [Stateful][dumb-comp] react components. These are usually top-level route handlers.
6667
- `components/`: [Stateless/Dumb][dumb-comp] react components. These guys determininstically render based on props.
6768

69+
70+
### Configuration Values
71+
72+
Configuration values are stored in the `config/` directory. You gain access to the configuration values by importing the config object from `config/index.js`. The configuration values are loaded as such:
73+
74+
1. The values in `config/default.js`
75+
2. The values in `config/{{APP_ENV}}.js` where `APP_ENV` is an environment variable.
76+
3. If `APP_ENV` is not set, `config/development.js` will be loaded by default.
77+
78+
[the logic for loading the config is here](https://github.com/UTD-CRSS/app.exploreapollo.org/blob/master/config/index.js).
79+
80+
#### Example
81+
82+
We use the configuration file to determine the API entry point in our actions.
83+
84+
1. [import the configuration object](https://github.com/UTD-CRSS/app.exploreapollo.org/blob/a999375d881ed763fd18b852b402582b5a6e647b/src/actions/index.js#L5)
85+
2. [use the configuration object](https://github.com/UTD-CRSS/app.exploreapollo.org/blob/a999375d881ed763fd18b852b402582b5a6e647b/src/actions/index.js#L31)
86+
3. If the `APP_ENV` is set to `staging`, [this](https://github.com/UTD-CRSS/app.exploreapollo.org/blob/a999375d881ed763fd18b852b402582b5a6e647b/config/staging.js#L3) will be the value for `config.apiEntry`.
87+
88+
Consider the following example commands:
89+
90+
```bash
91+
npm run dev # runs dev server with development API
92+
APP_ENV=staging npm run dev # runs dev server with staging API
93+
APP_ENV=production npm run dev # runs dev server with production API
94+
```
95+
6896
[nvm]: https://github.com/creationix/nvm
6997
[jest]: https://facebook.github.io/jest/
7098
[dumb-comp]: https://github.com/uberVU/react-guide/blob/master/props-vs-state.md#component-types

0 commit comments

Comments
 (0)