A reference implementation of the Five Bells Ledger API
You can see the ledger in action as part of the five-bells-demo
!
To run the ledger as a standalone server:
git clone https://github.com/interledgerjs/five-bells-ledger.git
cd five-bells-ledger
npm install
To run it using an in-memory database (the simplest option), run:
LEDGER_ADMIN_PASS=mypassword LEDGER_DB_URI=sqlite://:memory: npm start
Or run:
npm start
See "Environment Variables" in the generated documentation for config options.
After installation:
npm run docs
Open apidocs-out/index.html
in a web browser to see the generated API documentation.
This project can be run in a Docker container.
You need a local database instance listening on port 8080. Here is how to set that up:
docker run --name mysql -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 -d mysql
export LEDGER_DB_URI=mysql://root:password@localhost/fivebells
npm run migrate
Then run the following (with the same environment variables) as described above:
docker run -it --rm --net=host -e LEDGER_PORT=1337 -e LEDGER_DB_URI=$LEDGER_DB_URI interledger/five-bells-ledger
Breaking down that command:
-it
Run Five Bells Ledger in an interactive terminal.--rm
Delete container when it's done running.--net=host
Don't isolate container into its own virtual network. This allows Five Bells Ledger to see the database that we set up above.-e LEDGER_PORT=1337
Set the ledger's port to 1337. This is just an example for how to set a config option.
To run tests using an in-memory database, run:
npm test
If you wish to specify the database against which the tests are run, use the LEDGER_UNIT_DB_URI
environment variable.
LEDGER_UNIT_DB_URI=postgres://root:password@localhost:5432/ledger_test_db npm test
For example, to run against a Postgres instance in Docker, first start the database server:
docker run -it --rm --name fbl-pg-test postgres
Then, in another terminal, run the tests:
LEDGER_UNIT_DB_URI=postgres://postgres@`docker inspect --format '{{ .NetworkSettings.IPAddress }}' fbl-pg-test`/postgres npm test