GitHub Codespaces is enabled for this repository for everyone who is a member of the organization or acknowledged as an invited "Outside Collaborator".
You can learn more about using Codespaces from the official GitHub documentation.
ℹ️ When using the Codespaces environment, you should be provided all of the environment variables necessary to get up and running. However, if you find that any of them are not working as expected (please let us know!), you may need to manually update some of them via directions in the Configuration section below.
We recommend using VS Code with the Microsoft "Remote Development" extension pack to quickly spin up a full-featured development environment using Docker on your local system:
- Follow the installation guide
- Then either:
- Clone the repository locally and follow the quick start guide to open that folder in a container;
- Or follow the quick start guide to open a container for the repository or a pull request without cloning it to your local system
If you are using a MacOS or Linux system, you can setup all of the prerequisites by running one convenient script:
script/bootstrap
Here are some steps you can follow to install the prerequisites on RHEL, CentOS or Fedora Linux.
First, reset and install a more recent version of Node.js like version 16.
sudo yum module reset -y nodejs
sudo yum module install -y nodejs:16
Next, install the Node.js and Node.js Package Manager packages.
pkcon install -y nodejs
Ensure a modern version of Node.js (and npm) are installed.
Currently used versions in production:
- Node.js @
14.x
- npm @
6.x
Ensure a PostgreSQL server is installed and running.
Currently used version in production:
- PostgreSQL @
13.x
-
Clone the repository.
-
If you are using a MacOS or Linux system, you can setup all of the prerequisites by running one convenient script:
script/bootstrap
If you can successfully run that script, you may skip ahead to Step 5.
Here are some steps you can follow to install the PostgreSQL relational database on RHEL, CentOS or Fedora Linux.
pkcon install -y postgresql-server
- Install the dependencies. From a terminal, navigate to the project's root directory and run:
npm install
ℹ️ This should should not be necessary if you successfully ran script/bootstrap
.
- Create and seed the local PostgreSQL databases:
npm run db:create
followed by
npm run db:seed
ℹ️ This should should not be necessary if you successfully ran script/bootstrap
.
-
Ensure you have configured your environment.
-
Run the tests to ensure everything is working as expected:
npm test
- Start the server:
# Simple approach
npm run dev
- Using your preferred Google account, head to the Google API Console's Credentials page to create a new Project and API key. If you need a bit more guidance, refer to Google's guide.
- Hit the following URL, substituting your own API key in:
https://www.googleapis.com/civicinfo/v2/elections?key=<YOUR_API_KEY>
Chances are likely that you will receive a 403
response with an error message in the JSON response body explaining that you must enable the Google Civic Information API for your new Project. It will also provide a URL to visit to do just that (enable it), so please navigate to that. For reference, its format will be similar to:
https://console.developers.google.com/apis/api/civicinfo.googleapis.com/overview?project=<YOUR_PROJECT_ID>
- On the resulting page, click the "Enable" button.
- Revisit the URL from the earlier step, substituting your own API key in:
https://www.googleapis.com/civicinfo/v2/elections?key=<YOUR_API_KEY>
This time around, you should succeed with a JSON response body containing an elections
array.
- Create a file called
.env
in the project's root directory, preferrably using the.env.example
file as your template. - Add a new key-value pair to the file containing your new API key, e.g.
# API key for the Google Civic API
CIVIC_API_KEY=<YOUR_API_KEY>
- Save the changes to the
.env
file.
- Login to your personal Heroku dashboard.
- Switch to the
programequity
team under the project dropdown (which probably defaulted toPersonal
).
- ℹ️ If you do not see that team, you probably need to be added by a project administrator.
- Go into the backend application, currently named
murmuring-headland-63935
. - Go into the "Settings" tab.
- In the "Config Vars" section, click the "Reveal Config Vars" button to expand the list of existing environment variables.
- Find the
LOB_API_KEY
andTEST_LOB_API_KEY
variables. - Create a file called
.env
in the project's root directory, preferrably using the.env.example
file as your template. - Add a set of new key-value pairs to the file containing the API keys with the values from the Heroku application, e.g.
# Production environment API key for the Lob API
LOB_API_KEY=<HEROKU_VARIABLE>
# Test environment API key for the Lob API
# This is only required for running the integration tests successfully!
TEST_LOB_API_KEY=<HEROKU_VARIABLE>
- Save the changes to the
.env
file.
Although the authentication check is not required locally, the module in use still expects certain values to be passed in regardless of their validity.
- Create a file called
.env
in the project's root directory, preferrably using the.env.example
file as your template. - Add set of a new key-value pairs to the file with literal nonsense values, e.g.
SERVER_PORT=8080
CLIENT_ORIGIN_URL=http://localhost:8080
AUTH0_AUDIENCE=your_Auth0_identifier_value
AUTH0_DOMAIN=your_Auth0_domain
- Save the changes to the
.env
file.
- Follow the steps for
Ignoring the Auth0 authentication locally
for configuring the .env file. - Create a file called
.env
in the project's root directory, preferrably using the.env.example
file as your template. - Add set of a new key-value pairs to the file with literal nonsense values, e.g.
SERVER_PORT=8080
CLIENT_ORIGIN_URL=http://localhost:8080
AUTH0_AUDIENCE=
AUTH0_DOMAIN=
- Save the changes to the
.env
file.
The following instructions can also be found in this guide
- Sign up for an account at Auth0.
- Select
personal
when prompted with the type of account being created. - Go to API dashboard and click
Create API
button. - Add a Name to your API. It can be named anything you'd like.
- Set the Identifier value.
http://localhost:8080/
is recommended. For more information see this guide - Set
AUTH0_AUDIENCE=http://localhost:8080/
or another Identifier value from the step above. - Click on the "Test" tab.
- Locate the section called " Asking Auth0 for tokens from my application".
- Click on the cURL tab to show a mock POST request.
- Copy your Auth0 domain, which is part of the --url parameter value: tenant-name.region.auth0.com. For more information see this guide
- In .env, set
AUTH0_DOMAIN
value equal to domain value from step above.
-
Using your authorized Heroku account, you can find the
DATABASE_URL
Config Var on our deployed Heroku app's "Settings" page. -
Create a file called
.env
in the project's root directory, preferrably using the.env.example
file as your template. -
Add a new key-value pair to the file containing the Heroku
DATABASE_URL
value, e.g.
# PostgreSQL database connection string for production
DATABASE_URL=<OUR_HEROKU_DATABASE_URL>
- Save the changes to the
.env
file. - When starting your local server, you must set your
NODE_ENV
environment variable to"production"
in order forknex
to connect to this Heroku production database, e.g.
NODE_ENV=production npm start