This is an example project intended to show how React can work together with the R Plumber package.
To build:
- Make sure to run
npm install
within the express and client directories. - You'll need to set up some environment variables for both the react client and the express server. See below for details.
- The API can be deployed through an RSConnect instance or a Docker container.
- The
buildme
script will create production builds of the client and express server, intended for use in aws elastic beanstalk. However, it should work well in any express server.
For developing in React, we bypass the proxy and just hit the plumber instance directly. To do so, you'll want two env files:
.env
will contain:
REACT_APP_API_URL=/proxy
REACT_APP_API_PATH=<PATH TO YOUR PLUMBER API>
.env.development.local
will contain:
REACT_APP_API_URL=<YOUR PLUMBER DOMAIN>
REACT_APP_API_KEY=<YOUR KEY HERE>
Your Express environment will also need to be set. For this example we use the convenient package dotenv, but these could also be set on the command line or through other methods.
The .env file should contain:
EXPRESS_PLUMBER_API_URL=https://pam-npn.intranet.mckinsey.com EXPRESS_PLUMBER_API_KEY=YVGVZKrqVnmLIZfTYufMNHNUSKk950p2
This is a work in progress, so if you're interested, please try it out and reach out to me. I'm sure it can be improved upon.