Note: Before completing this guide, make sure you have completed the general onboarding guide in the base mojaloop repository.
- Prerequisites
- Installing and Building
- Running Locally
- Running Inside Docker
- Testing
- Common Errors/FAQs
If you have followed the general onboarding guide, you should already have the following cli tools installed:
brew
(macOS), [todo: windows package manager]curl
,wget
docker
+docker-compose
node
,npm
and (optionally)nvm
In addition to the above cli tools, you will need to install the following to build and run the quoting-service
:
#none - you have everything you need!
[todo]
[todo]
Firstly, clone your fork of the quoting-service
onto your local machine:
git clone https://github.com/<your_username>/quoting-service.git
Then cd
into the directory and install the node modules:
cd quoting-service
npm install
If you run into problems running
npm install
, make sure to check out the Common Errors/FAQs below.
In this method, we will run all of the dependencies inside of docker containers, while running the quoting-service
server on your local machine.
Alternatively, you can run the
quoting-service
inside ofdocker-compose
with the rest of the dependencies to make the setup a little easier: Running Inside Docker.
1. Set up the MySQL container, and give it time to initialize
Note: Before starting all of the containers, start the
mysql
container alone, to give it some more time to set up the necessary permissions (this only needs to be done once, or every time you remove and re-create the container).
docker-compose -f docker-compose.base.yml up mysql
2. Run all of the dependencies in docker-compose
:
# start all the dependencies inside of docker - these services are defined in docker-compose.base.yml
docker-compose -f docker-compose.base.yml up
3. Configure the default files and run the server
# (optional) edit the default config in config/default.json
# start the server
npm run start
Upon running npm run start
, your output should look similar to:
> [email protected] start <path_to>/quoting-service
> node src/server.js
2019-06-04T11:06:56Z, [log,info] data: Server running on http://0.0.0.0:3002
4. Verify the quoting-service is running with the health check
Hit the health check endpoint to verify the server is up and running:
curl localhost:3002/health
You should see the following:
{"status":"OK"}
We use docker-compose
to manage and run the quoting-service
along with its dependencies with one command.
Note: Before starting all of the containers however, start the
mysql
container alone, to give it some more time to set up the necessary permissions (this only needs to be done once). This is a short-term workaround because thecentral-ledger
doesn't retry it's connection to MySQL.
1. First run the mysql container, then run the test of the containers
docker-compose -f docker-compose.base.yml up mysql #first time only - the initial mysql load takes a while, and if it's not up in time, the central-ledger will just crash
npm run docker:up
This will do the following:
docker pull
down any dependencies defined in thedocker-compose.yml
filedocker build
thequoting-service
image based on theDockerfile
defined in this repo- run all of the containers together
You can run docker-compose
in 'detached' mode as follows:
npm run docker:up -- -d
And then attach to the logs with:
docker-compose logs -f
When you're done, don't forget to stop your containers however:
npm run docker:stop
We use npm
scripts as a common entrypoint for running the tests.
# unit tests
npm run test
# check test coverage
npm run cover
Refer to the central-ledger onboarding guide to test the quoting-service
using postman.
Note: Before running the postman scripts, ensure you have populated the test data using the
test/util/scripts/populateTestData.sh
in thecentral-ledger
directory. For more information, follow the Runningcentral-ledger
Inside Docker guide
Resolved by installing v2.0.3 npm install [email protected]
Resolved by running CXX='clang++ -std=c++11 -stdlib=libc++' npm rebuild
Undefined symbols for architecture x86_64:
"_CRYPTO_cleanup_all_ex_data", referenced from:
_rd_kafka_transport_ssl_term in rdkafka_transport.o
"_CRYPTO_num_locks", referenced from:
........
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Resolved by installing openssl brew install openssl
and then running:
export CFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib
npm install