Skip to content

Commit

Permalink
Use env variables for api url (client)
Browse files Browse the repository at this point in the history
  • Loading branch information
arielger committed Mar 22, 2019
1 parent 57d73df commit 52aa963
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Truco

[![Netlify Status](https://api.netlify.com/api/v1/badges/b8179712-8947-491c-b0c9-1cfa8b4ddfbd/deploy-status)](https://app.netlify.com/sites/truco/deploys)

Multiplayer truco game made with GraphQL and React.

## Development

### Client

You will need to create a `.env` file following the provided `.env.example` file.

```
yarn install
yarn start
```

### Server

You will need to create a `.env` file following the provided `.env.example` file.

```
yarn install
yarn start
```
4 changes: 4 additions & 0 deletions client/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
REACT_APP_API_URL=http://localhost:4000
REACT_APP_SUBSCRIPTIONS_URL=ws://localhost:4000/graphql
ENGINE_API_KEY=apolloEngineApiKey

17 changes: 10 additions & 7 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ const authLink = setContext((_, { headers = {} }) => {
});

const networkInterface = new HttpLink({
uri: "http://localhost:4000"
uri: process.env.REACT_APP_API_URL
});

// Create WebSocket client
const wsClient = new SubscriptionClient(`ws://localhost:4000/graphql`, {
reconnect: true,
connectionParams: () => ({
authorization: localStorage.getItem("token") || ""
})
});
const wsClient = new SubscriptionClient(
process.env.REACT_APP_SUBSCRIPTIONS_URL,
{
reconnect: true,
connectionParams: () => ({
authorization: localStorage.getItem("token") || ""
})
}
);

const webSocketLink = new WebSocketLink(wsClient);

Expand Down
2 changes: 1 addition & 1 deletion client/src/screens/Match/Scores/Scores.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

import styles from "./Scores.module.scss";
// import styles from "./Scores.module.scss";

// @todo: Add animation to new points
export default function Scores({ matchPoints, myPoints, theirPoints }) {
Expand Down

0 comments on commit 52aa963

Please sign in to comment.