Skip to content

Commit

Permalink
Merge pull request #4 from davslabs/feature/web-9-Agregar.env-y-run-t…
Browse files Browse the repository at this point in the history
…unnel

Feature/web 9 agregar.env y run tunnel
  • Loading branch information
davslabs committed Oct 25, 2022
2 parents aaaecea + 227a8f0 commit c82d30d
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Si se modifican variables en .env, es necesario ejecutar el comando "expo r -c" para reconstruir el cache
* de otro modo, el modulo react-native-dotenv utiliza los valores cacheados y no se ven reflejadas las actualizaciones
*/
API_BASE_URL="http://10.0.2.2:3000/api/v1"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ npm-debug.*
*.mobileprovision
*.orig.*
web-build/
.env

# macOS
.DS_Store
Expand Down
12 changes: 12 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = function (api) {
api.cache(() => process.env.NODE_ENV === "production");
return {
presets: ['babel-preset-expo'],
plugins: [
[
'module:react-native-dotenv',
{ moduleName: '@env', path: '.env', blacklist: null, whitelist: null, safe: false, allowUndefined: true },
],
],
};
};
47 changes: 47 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"prepare": "husky install",
"start": "expo start",
"tunnel": "expo start --tunnel",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
Expand All @@ -19,12 +20,14 @@
"@react-navigation/native": "^6.0.13",
"@react-navigation/native-stack": "^6.9.1",
"axios": "^1.1.3",
"babel": "^6.23.0",
"expo": "~46.0.16",
"expo-secure-store": "^11.3.0",
"expo-status-bar": "~1.4.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-native": "0.69.6",
"react-native-dotenv": "^3.3.1",
"react-native-web": "~0.18.7"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/api/axios.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import axios from 'axios';

const BASE_URL = 'http://10.0.2.2:3000/api/v1';
import { API_BASE_URL } from '@env';

export default axios.create({
baseURL: BASE_URL,
baseURL: `${API_BASE_URL}`,
});

export const axiosPrivate = axios.create({
baseURL: BASE_URL,
baseURL: `${API_BASE_URL}`,
headers: { 'Content-Type': 'application/json' },
withCredentials: true,
});
3 changes: 3 additions & 0 deletions src/types/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module '@env' {
export const API_BASE_URL: string;
}

0 comments on commit c82d30d

Please sign in to comment.