Welcome to the LendsQR API, you can view the live API here.
The entire application is contained within the index.tsx
file which is in the src
directory.
The application is in a docker container with node version node:16.16.0-alpine
which is the LTS at the writing of this API.
Make sure you have docker and node installed on your pc, then run
npm i
to install the package dependencies. Also provide the .env
file in the root directory as stated in .env.example
file.
Make sure docker has started before running any of the commands below.
docker-compose -f docker-compose.yaml -f docker-compose.dev.yaml up -d --build
docker-compose -f docker-compose.yaml -f docker-compose.dev.yaml down
docker-compose -f docker-compose.yaml -f docker-compose.dev.yaml up -d
docker-compose -f docker-compose.yaml -f docker-compose.prod.yaml build
docker logs -f lendsqr-api
docker exec -it lendsqr-api /bin/sh
The application is behind an nginx proxy server which is listening on port 80. After you've started the application, visit the endpoint below to make sure its running properly
http://localhost
You should get the message below
{
"message": "Welcome to LendsQR api 🔥🔥🔥"
}
To create an up migrations
npm run knex:migrate
To create a down migration
npm run knex:rollback
The test uses an in memory database
for sqlite3, hence making the tests extremely fast.
npm run test
All tests are written in the src/__test__
directory.
The REST API to the lendsqr app is described below. The base URL is
http://localhost/api/v1
The base URL for the live version is
https://ifeoluwa-lendsqr-api.herokuapp.com/api/v1
POST /auth/register
{
"email": "[email protected]",
"fullName": "Janet Doe",
"password": "password"
}
{
"message": "success",
"data": {
"id": 17,
"fullName": "Janet Doe",
"email": "[email protected]"
}
}
POST /auth/signin
{
"email": "[email protected]",
"password": "password"
}
{
"message": "success",
"data": {
"id": 17,
"fullName": "Janet Doe",
"email": "[email protected]",
"createdAt": "2022-08-16T03:51:18.000Z",
"updatedAt": "2022-08-16T03:51:18.000Z"
}
}
GET /auth/signout
{}
{
"message": "success",
"data": {
"message": "Logged out successfully"
}
}
GET auth/current-user
{}
{
"message": "success",
"currentUser": {
"id": 17,
"email": "[email protected]",
"iat": 1660638949
}
}
- accountType can either be Savings or Current
- currency can either be USD or NGN
- passcode must be of length 4
POST /account
{
"accountType": "Savings",
"currency": "USD",
"passcode": 1234
}
{
"message": "success",
"data": {
"id": 9,
"accountNumber": "2444594569",
"balance": "0",
"type": "Savings",
"currency": "USD",
"createdAt": "2022-08-16T08:37:10.000Z",
"updatedAt": "2022-08-16T08:37:10.000Z",
"userID": 17
}
}
POST /account/fund
{
"amount": "500"
}
{
"message": "success",
"data": {
"message": "Account has been funded"
}
}
GET /account
{}
{
"message": "success",
"data": {
"id": 9,
"accountNumber": "2444594569",
"balance": "5000",
"type": "Savings",
"currency": "USD",
"createdAt": "2022-08-16T08:37:10.000Z",
"updatedAt": "2022-08-16T08:37:10.000Z",
"userID": 17
}
}
Transfer uses transaction to ensure that the entire transfer workflow is seen through till the end. Hence, all changes are reverted if an error occurred at any point during the transfer process.
POST /account/transfer
{
"amount": "100",
"recipientAccount": "5317717302",
"passcode": "1234"
}
{
"message": "success",
"data": {
"transfer": "Completed"
}
}
POST /account/withdraw
{
"amount": 2000,
"passcode": 1234
}
{
"message": "success",
"data": {
"withdrawal": "Completed"
}
}
Custom errors are thrown for each endpoint depending on the validation that has failed