Task 1: Create a new api endpoint for getting user balance
The api endpoint should be GET /api/v1/users/getUserBalance, the initial code is already in place, you just need to implement the logic to get the user balance from the database and return it as a response. The response should be in the format below:
{
"message": "User balance retrieved successfully",
"balance": "1000"
}
Task 2: Create a new api endpoint for getting user transactions
The api endpoint should be GET /api/v1/users/getTransactionsByUser, the initial code is already in place, you just need to implement the logic to get the user transactions from the database and return it as a response. The response should be in the format below:
{
"message": "User transactions retrieved successfully",
"transactions": [
{
"id": "1",
"amount": "1000",
"type": "credit",
"createdAt": "2021-07-01T00:00:00.000Z"
},
{
"id": "2",
"amount": "500",
"type": "debit",
"createdAt": "2021-07-01T00:00:00.000Z"
}
]
}
If we send a query parameter showBalance, it will return balance as well, so the response will be in the format below:
{
"message": "User transactions retrieved successfully",
"balance": 500,
"transactions": [] // array of transactions
}
Task 1: Create a new api endpoint for getting user balance
The api endpoint should be
GET /api/v1/users/getUserBalance, the initial code is already in place, you just need to implement the logic to get the user balance from the database and return it as a response. The response should be in the format below:{ "message": "User balance retrieved successfully", "balance": "1000" }Task 2: Create a new api endpoint for getting user transactions
The api endpoint should be
GET /api/v1/users/getTransactionsByUser, the initial code is already in place, you just need to implement the logic to get the user transactions from the database and return it as a response. The response should be in the format below:{ "message": "User transactions retrieved successfully", "transactions": [ { "id": "1", "amount": "1000", "type": "credit", "createdAt": "2021-07-01T00:00:00.000Z" }, { "id": "2", "amount": "500", "type": "debit", "createdAt": "2021-07-01T00:00:00.000Z" } ] }If we send a query parameter
showBalance, it will return balance as well, so the response will be in the format below:{ "message": "User transactions retrieved successfully", "balance": 500, "transactions": [] // array of transactions }