From f17911f8521f56e3c3a1e1f7f6703ce36261efc9 Mon Sep 17 00:00:00 2001 From: Sorrel Bri Date: Tue, 7 Jan 2020 13:03:59 -0800 Subject: [PATCH] stub basic connection --- packages/play-node-go/package.json | 7 +++++-- packages/play-node-go/server/bin/www | 2 +- packages/play-node-go/src/App.js | 4 ++++ packages/play-node-go/src/config.js | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 packages/play-node-go/src/config.js diff --git a/packages/play-node-go/package.json b/packages/play-node-go/package.json index 391611b..6b60eac 100644 --- a/packages/play-node-go/package.json +++ b/packages/play-node-go/package.json @@ -13,11 +13,14 @@ "socket.io-client": "^2.3.0" }, "scripts": { - "start": "react-scripts start", + "start": "REACT_APP_ENVIRONMENT='development' react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", - "flow": "flow" + "flow": "flow", + + "predeploy": "REACT_APP_ENVIRONMENT=production npm run build" + }, "eslintConfig": { "extends": "react-app" diff --git a/packages/play-node-go/server/bin/www b/packages/play-node-go/server/bin/www index 0a437c1..ec05bde 100755 --- a/packages/play-node-go/server/bin/www +++ b/packages/play-node-go/server/bin/www @@ -12,7 +12,7 @@ var http = require('http'); * Get port from environment and store in Express. */ -var port = normalizePort(process.env.PORT || '3000'); +var port = normalizePort(process.env.PORT || '8000'); app.set('port', port); /** diff --git a/packages/play-node-go/src/App.js b/packages/play-node-go/src/App.js index 739ff0f..241ed97 100644 --- a/packages/play-node-go/src/App.js +++ b/packages/play-node-go/src/App.js @@ -1,10 +1,14 @@ import React from 'react'; import './App.scss'; +import config from './config'; function App() { + let fetchData = {}; + fetch(config.apiAddress).then(res => {console.log(res);fetchData = res.body}).then(() => console.log(fetchData)) return (

React Boilerplate

+ {fetchData ?

: <>}
); } diff --git a/packages/play-node-go/src/config.js b/packages/play-node-go/src/config.js new file mode 100644 index 0000000..d54c463 --- /dev/null +++ b/packages/play-node-go/src/config.js @@ -0,0 +1,15 @@ +const production = { + apiAddress: null +} + +const development = { + apiAddress: 'http://localhost:8000' +} + +const config = process.env.REACT_APP_ENVIRONMENT === 'production' + ? production + : development + +export default { + ...config +} \ No newline at end of file