This project is a Node.js application that connects to a PostgreSQL database using Sequelize ORM. It provides APIs for user management, including fetching user details, updating user balance, and resetting user balance. The application is designed for high performance and reliability, employing transactions and error handling to ensure data integrity. Additionally, the application uses Sequelize to perform database migrations and manage concurrency in database operations, ensuring consistent and efficient data access in a concurrent environment.
- Fetch all users
- Update user balance with atomic transactions
- Reset user balance to a default value
- Error handling middleware for graceful error responses
-
Clone the repository:
git clone https://github.com/yourusername/your-repo.git cd your-repo -
Install dependencies:
npm install
-
Create a
.envfile:DIALECT=postgres DB_HOST=************** DB_PORT=5432 DB_USERNAME=************** DB_PASSWORD=************** DB_NAME=**************
-
Start the application:
npm start
- Endpoint:
/users - Method:
GET
- Endpoint:
/users/:userId/balance - Method:
PUT - Body Parameters:
amount(number) - The amount to be added to the user's balance
- Endpoint:
/reset - Method:
GET