Skip to content

Commit

Permalink
[#36] Development backend server env
Browse files Browse the repository at this point in the history
  • Loading branch information
dedenbangkit committed Jul 4, 2023
1 parent c9954dc commit 9af4fce
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
3 changes: 3 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ web-build/

# coverage generated by jest
coverage

# generated env from docker
.env
10 changes: 10 additions & 0 deletions app/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ module.exports = function (api) {
['@babel/plugin-transform-class-properties', { loose: true }],
['@babel/plugin-transform-private-methods', { loose: true }],
['@babel/plugin-transform-private-property-in-object', { loose: true }],
[
'module:react-native-dotenv',
{
moduleName: '@env',
path: '.env',
blocklist: ['GITHUB_TOKEN'],
safe: false,
allowUndefined: true,
},
],
],
};
};
25 changes: 25 additions & 0 deletions app/package-lock.json

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

1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"jest-expo": "^48.0.2",
"jest-react-native": "^18.0.0",
"prettier": "2.8.8",
"react-native-dotenv": "^3.4.9",
"react-native-testing-library": "^6.0.0",
"react-test-renderer": "^18.2.0"
},
Expand Down
9 changes: 9 additions & 0 deletions app/src/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { SERVER_URL } from '@env';
import build_json from './build.json';

const defaultBuildParams = {
...build_json,
serverURL: SERVER_URL,
};

export default defaultBuildParams;
2 changes: 1 addition & 1 deletion app/src/build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"authenticationType": ["code_assignment", "username", "password"],
"serverURL": "https://api.example.com/nmis",
"serverURL": null,
"debugMode": false,
"dataSyncInterval": 300,
"errorHandling": true,
Expand Down
2 changes: 1 addition & 1 deletion app/src/lib/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import defaultBuildParams from '../build.json';
import defaultBuildParams from '../build.js';

export const config = {
baseURL: defaultBuildParams?.serverURL, // server URL from setting
Expand Down
2 changes: 1 addition & 1 deletion app/src/store/buildParams.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Store } from 'pullstate';
import defaultBuildParams from '../build.json';
import defaultBuildParams from '../build';

const BuildParamsState = new Store({
authenticationType: defaultBuildParams?.authenticationType || [
Expand Down
1 change: 1 addition & 0 deletions app/start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh

echo "SERVER_URL=${BACKEND_IP_ADDRESS}" > .env
npm install
npm start
2 changes: 2 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
version: "3.9"
services:
mobileapp:
environment:
- BACKEND_IP_ADDRESS=http://${IP_ADDRESS}:8080
volumes:
- nmis-mobile-sync:/app/node_modules:nocopy
backend:
Expand Down

0 comments on commit 9af4fce

Please sign in to comment.