Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove config.js in favor of .env #92

Merged
merged 3 commits into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
PORT=3001

REACT_APP_BACKEND_HOST="http://localhost:3000"
REACT_APP_BACKEND_VERSION="> 0.0.0-90"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that the backend version requirement should be part of the .env file. It is a requirement that the code makes, not one that the server makes. Maybe we should keep a config.js for things like this and have an additional .env file for things like the backend host address.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a good solution would be to specify the backend version in the package.json file (custom fields are allowed), but importing the file (and all other files outside of src) is currently not allowed. There is a PR for that however that seems to be near completion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a work-around for now, I can symlink package.json to src/config.json. Any downsides to symlinks in git?

4 changes: 3 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import styled from 'styled-components'
import routes from './routes'
import ReactCSSTransitionReplace from 'react-css-transition-replace'

const backendVersion = process.env.REACT_APP_BACKEND_VERSION

const App = (props) =>
<div className={props.className}>
<GlobalMenu />
Expand Down Expand Up @@ -42,7 +44,7 @@ const App = (props) =>
/>
)}
</Switch>
<VersionWarning requirement={props.config.version} />
<VersionWarning requirement={backendVersion} />
</div>

const StyledApp = styled(App)`
Expand Down
5 changes: 3 additions & 2 deletions src/apollo/client.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ApolloClient, createNetworkInterface } from 'react-apollo'
import config from '../config'

const backendHost = process.env.REACT_APP_BACKEND_HOST

const networkInterface = createNetworkInterface({
uri: `${config.api.endpoint}/graphql`
uri: `${backendHost}/graphql`
})
networkInterface.use([
{
Expand Down
25 changes: 0 additions & 25 deletions src/config.js

This file was deleted.

3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import ReactDOM from 'react-dom'
import registerServiceWorker from './registerServiceWorker'
import config from './config'
import App from './App'
import { BrowserRouter as Router } from 'react-router-dom'
import { ApolloProvider } from 'react-apollo'
Expand All @@ -14,7 +13,7 @@ ReactDOM.render(
<ApolloProvider client={client}>
<Router>
<ThemeProvider theme={theme}>
<App config={config} />
<App />
</ThemeProvider>
</Router>
</ApolloProvider>,
Expand Down