On the QLDB page on AWS management console, perform the following operation:
- Create a ledger with name bank or any other name. Ensure to use the correct ledger name in the config file (Config.toml)
- Create table
CREATE TABLE accounts
- Create index on table
CREATE INDEX ON accounts (account_number)
- Create .env file at the root of the project with the following details.
RUST_LOG=info,actix_web=info
SERVER_PORT=8080
LEDGER_NAME=bank
In the project root directory, type the command below to run
cargo run
Change the http_port and ledger_name in the configuration file (Config.toml) as you see fit. Default Base URL: http://locathost:8080
GET /account
- get all accountsGET /account/{account_number}
- get account details by account_numberPOST /account
- Create new account. This returns a JSON response including the account_number and default balance of 0.DELETE /account/{account_number}
- delete account by account_numberPOST /transaction
- Process transaction based on JSON payload.
{
"name": "Sam James",
"phone": "2347038657970"
}
{
"amount": "50",
"recipient_account_number": "565656565",
"transaction_type": "DEBIT"
}
{
"amount": "100",
"recipient_account_number": "565656565",
"transaction_type": "CREDIT"
}
{
"amount": "50",
"recipient_account_number": "565656565",
"sender_account_number": "3971240165",
"transaction_type": "TRANSFER"
}