BAT back-end servers (ledger, eyeshade, balance, and helper)
Authentication is achieved via a GitHub OAuth application. Create a developer application with an authorization callback of the form https://{DOMAIN:PORT}/v1/login
. Set the environment variables GITHUB_CLIENT_ID
and GITHUB_CLIENT_SECRET
to those corresponding in your OAuth application.
Authorization is achieved by verifying that the user is a member of a GitHub organization, i.e., https://github.com/orgs/{ORGANIZATION}/teams
. Set the GITHUB_ORG
environment variable to this address.
- Clone the repo:
git clone https://github.com/brave-intl/bat-ledger.git
- Install CMake:
brew update && brew install cmake
- Install Redis:
brew install redis
- Install MongoDB:
brew install mongodb
- Set MongoDB URI env variable:
export MONGODB_URI=localhost/test
- Install the dependencies
npm install
- Start Redis
brew services start redis
- Start MongoDB
brew services start mongodb
- Start with
npm run start-[ledger|eyeshade|balance|helper]
If you get an error when starting a service, try clearing the Redis database:
redis-cli
> flushdb
First, install docker and docker compose.
Check out https://github.com/brave-intl/bat-ledger
You can add any environment variables that need to be set by creating a .env
file at the top of the repo. Docker compose will automatically load from this
file when launching services.
e.g. you might have the following in .env
:
PUBLISHERS_TOKEN=foo
PUBLISHERS_URL=http://docker.for.mac.localhost:3000
# Build the base image:
docker-compose build
# (Optional) Build the bat-go image according to instructions @ https://github.com/brave-intl/bat-go
# 1. If you built bat-go you can then bring up all services (ledger, eyeshade, balance and grant)
docker-compose up
# 2. If you did not build bat-go, limit the services being brought up to exclude the grant service
docker-compose up ledger-web ledger-worker eyeshade-web eyeshade-worker balance-web
# Logs from all services presented interleaved, you can press ctrl-c to stop.
# Ledger listens on port 3001, eyeshade on 3002, and balance on 3003
# Note you can run any subset of services (e.g. only eyeshade)
docker-compose up eyeshade-web eyeshade-worker
# You can also launch and run services in the background
docker-compose up -d eyeshade-web eyeshade-worker
# And stop running background services with
docker-compose stop
Configuration variables are stored as environment preferences. See config.js
for a list of these variables for ledger, eyeshade, balance, and helper respectively.
If you intend to run eyeshade in communication with the publisher's website, you will need to set the UPHOLD_CLIENT_ID
and UPHOLD_CLIENT_SECRET
environment variables to the same as those used on your copy of the publishers site.
For linting we use StandardJS. It's recommended that you install the necessary IDE plugin. Since this repo uses ES7 features, you'll need a global install of both the standard and babel-eslint packages.
Please note: Some tests access live APIs and require auth tokens which are not stored in the repo.
- Copy example over:
cp .env.example .env
. - Confirm .env vars match the contents of
.travis.yml
section env.global. - Fill in the remaining
{CHANGE_ME}
.env vars appropriately; please consult your local BAT dev to find the answers.
npm run docker-build
npm run docker-up
npm run docker-test