The Expense Tracker API is built with Express, MongoDB, and Mongoose. It provides a secure and reliable backend for managing expenses and transactions. The API offers protected routes that require authentication, ensuring that only authorized users can access sensitive data.
To run this API locally, follow these steps:
- Clone the repository.
- Install the required dependencies by running
npm install
. - Create a
.env
file in the root directory and add the following environment variables:
MONGO_CONNECTION_KEY=your_mongodb_connection_key
JWT_SALT="my-secret-key-123"
NODEMAILER_USER=your_nodemailer_user
NODEMAILER_PASSWORD=your_nodemailer_password
- Start the server by running
npm start
.
You can access the live API at https://expense-tracker-api-3lv5.onrender.com/api/users.
POST /api/users/register
: Register a new user.
{
"name": "test",
"email": "test@gmail.com",
"password": "12345678",
"confirm_password": "12345678",
"balance": 100
}
POST /api/users/login
: User login.
{
"email": "test@gmail.com",
"password": "12345678"
}
POST /api/users/forgotpassword
: Send a password reset email.
{
"email": "test@gmail.com",
}
POST /api/users/resetpassword
: Reset user password.
{
"email": "test@gmail.com",
"reset_code": "41456",
"new_password": "newpassword"
}
GET /api/users/dashboard
: Get user dashboard information.
POST /api/transactions/addIncome
: Add an income transaction.
{
"amount": 10,
"remarks": "from someone"
}
POST /api/transactions/addExpense
: Add an expense transaction.
{
"amount": 10,
"remarks": "from someone"
}
GET /api/transactions
: Get all transactions./?transaction_type=income
: Filter by income or expense
DELETE /api/transactions/:transaction_id
: Delete a transaction by ID.PATCH /api/transactions
: Edit a transaction.
{
"remarks": "from someone else"
}
- url: http://localhost:8000/api
- accessToken: This should be automated by adding the test config below
- (Optional to test the live link) liveUrl: https://expense-tracker-api-3lv5.onrender.com/api/
- This is for automating the Access Token...
pm.environment.set("accessToken", pm.response.json().accessToken)
- Node.js
- ExpressJS
- MongoDB
- Mongoose
- jsonwebtoken
- nodemailer
- Mailtrap
- express-async-errors
- validator
- bcrypt
For any questions or feedback, please feel free to reach out to me at adiyambaojs@gmail.com.