This project is a NestJS-based API that aggregates transaction data for users. It includes endpoints to get aggregated data, request payouts, and mock server capabilities for testing purposes.
- Aggregate user transaction data such as balance, earned, spent, and payout.
- Poll transactions data from a given API periodically.
- Expose endpoints to add transactions dynamically (earned, spent, and payout).
- Unit tests for core service functionality.
- Node.js (v14 or higher)
- npm (v6 or higher)
-
Install Nest CLI globally if not already installed:
npm install -g @nestjs/cli
-
Clone the repository:
git clone <repository-url> cd aggregator
-
Install dependencies:
npm install
-
Start the application:
npm run start
-
The API server will run at
http://localhost:3000
by default. -
The API server will use transactions server run at
http://localhost:3001
by default. -
To access the Swagger API documentation, visit:
http://localhost:3000/api
To run the mock transactions server for testing:
-
Navigate to the directory containing the mock transactions API:
cd aggregator/transactions
-
Install dependencies:
npm install
-
Start the mock server:
npm run start
-
The mock server will be available at
http://localhost:3001
. -
To access the Swagger API documentation, visit:
http://localhost:3001/api
- Run the unit tests for the service layer:
npm run test
- GET /transactions/user/:userId - Get aggregated transaction data by user ID.
- GET /transactions/payouts - Get requested payouts aggregated by user ID.
- POST /transactions - Add a new transaction (
earned
,spent
, orpayout
).
This project is licensed under the MIT License.