If you do not have the latest version of stack, please remove whatever version of stack you have:
sudo apt remove haskell-stack
Then get the latest version of stack by running:
wget -qO- https://get.haskellstack.org/ | sh
To build the server, run:
stack build
PostgreSQL is used as the database backend. Before you run the server, make sure you have PostgreSQL 9 or higher installed.
To install, you can follow the instructions here.
Note that you may need to run the commands as a super user.
Create a Postgres account. There are good instructions here
Type in psql
and see that you can open up a psql
shell.
When first run you will need to inialise the database.
After that, to create the database, run:
createdb 'devsupplychainserver'
To initalise the database run:
stack exec supplyChainServer -- --brhost localhost --brport 8200 --init-db -c "dbname=<database name>"
The -c option takes a database connection string in libpq format.
Some examples are:
- "dbname=devsupplychainserver"`
- "postgresql://localhost/devsupplychainserver"
The default connection string is dbname=devsupplychainserver
.
Finally, to run the server, do:
stack exec supplyChainServer -- --brhost localhost --brport 8200
Then you can check out the API at:
http://localhost:8000/swagger-ui/
To use ghci interactively, run
stack ghci
If you find yourself deleting and recreating the database frequently, run
./restart.sh
. It will build your code, drop the database
devsupplychainserver
, create it anew and run the migration script
to create all the relevant tables.
To do a clean build instead, do ./restart.sh --clean
.
The run_tests.sh
script will run the tests (and makes sure they run single
threaded because the tests depend on previous tests), it should usually be run
as:
./run_tests.sh
# If you want a coverage report
./coverage.sh
# If you want to launch the report in the browser
./coverage.sh --launch
stack build --fast && dropdb testbusinessregistry && createdb testbusinessregistry && stack exec businessRegistry -- -c 'dbname=testbusinessregistry' --env Dev --log-level DebugS initdb
You'll need to run the above each time the BR db schema changes.
Some common acronyms used in the project.
SCS: Supply Chain Service
BR: Business Registry
- GS1 Company Database - You can search for GLN (Global Location Number) of GS1 Companies here