Backend API that wraps the ProPublic Congress API.
- Handles API Key securely
- Caches API requests for 24 hours
- Converts ProPublica API responses to jsonapi format
- Serves Ember site
Dependencies:
- Go 1.10.4
- dep v0.5.0
A ProPublica API key will be required. After registering with the Propublica Data Store, an email with the key will be sent.
The application has its settings passed in through a JSON configuration file. Below is an example of the required format. Please alter paths, ports and API key to fit your environment. See the Ember Frontend section for more information on the EmberPath variable.
{
"Port": 8080,
"EmberPath": "***/congress-ember/dist",
"ApiBase": "https://api.propublica.org/congress/v1",
"ApiKey": "***",
"CacheTimeOut": "24h"
}
Install Dependencies:
go get ./..
Alternative Installation of Dependencies (still in testing):
dep ensure
Run Server:
go run github.com/jalandis/congress-go-api/main.go --config_path ./config.json
After starting the server, the following url can be used to load an example JSON response to confirm proper setup.
http://localhost:8080/api/v1/legislation
This API project serves a Congress Ember application and will require the Ember app be built locally for testing, development, or demo.
Please follow the installation and build sections of the Ember README and update the EmberPath value in this projects json configuration to point to the Ember dist folder.
Format all code and run unit tests:
gofmt -s -w .
go test -race ./...
Evaluate test coverage:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
View documentation:
godoc -http=:6060
circleci local execute --job build