diff --git a/App/Config/.gitignore b/App/Config/.gitignore new file mode 100644 index 000000000..945ce43a9 --- /dev/null +++ b/App/Config/.gitignore @@ -0,0 +1 @@ +index.js \ No newline at end of file diff --git a/App/Config/README.md b/App/Config/README.md new file mode 100644 index 000000000..f12d87576 --- /dev/null +++ b/App/Config/README.md @@ -0,0 +1,25 @@ +This directory contains configuration variables in 3 files: +- `index.dev.js` : contains development variables +- `index.production.js` : contains production variables +- `index.staging.js` : contains beta tests variables + +You need to create `index.js` by copying the right file. + +#### Warning +Each time you need to build, you need to verify if your `index.js` is the right one. +For example, during development, before building your app do: +``` +cp App\Config\index.dev.js App\Config\index.js +``` +In other environment, you must pay attention to change your `index.js` with the good one. +Also, make sure you add each configuration variable in each configuration file. + +#### Usage +``` +import Config from 'App/Config' + +... +let uri = Config.API_URL +... + +``` \ No newline at end of file diff --git a/App/Config/index.dev.js b/App/Config/index.dev.js new file mode 100644 index 000000000..f91b3bfce --- /dev/null +++ b/App/Config/index.dev.js @@ -0,0 +1,4 @@ +export const Config = { + API_URL: 'https://query.yahooapis.com/v1/public/', + API_PREFIX: 'api', +} diff --git a/App/Config/index.production.js b/App/Config/index.production.js new file mode 100644 index 000000000..f91b3bfce --- /dev/null +++ b/App/Config/index.production.js @@ -0,0 +1,4 @@ +export const Config = { + API_URL: 'https://query.yahooapis.com/v1/public/', + API_PREFIX: 'api', +} diff --git a/App/Config/index.staging.js b/App/Config/index.staging.js new file mode 100644 index 000000000..f91b3bfce --- /dev/null +++ b/App/Config/index.staging.js @@ -0,0 +1,4 @@ +export const Config = { + API_URL: 'https://query.yahooapis.com/v1/public/', + API_PREFIX: 'api', +} diff --git a/App/Service/WeatherService.js b/App/Service/WeatherService.js index 712632608..1d9fc9933 100644 --- a/App/Service/WeatherService.js +++ b/App/Service/WeatherService.js @@ -1,7 +1,8 @@ import { create } from 'apisauce' +import { Config } from 'App/Config' const weatherApiClient = create({ - baseURL: 'https://query.yahooapis.com/v1/public/', + baseURL: Config.API_URL, headers: { Accept: 'application/json', 'Content-Type': 'application/json',