Skip to content

This API ensures a secure and reliable backend for handling expenses and transactions. It includes protected routes, requiring authentication to restrict access to authorized users for sensitive data.

Notifications You must be signed in to change notification settings

adsyam/Expense-Tracker-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expense Tracker API

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.

Installation

To run this API locally, follow these steps:

  1. Clone the repository.
  2. Install the required dependencies by running npm install.
  3. Create a .env file in the root directory and add the following environment variables:

(.env)

MONGO_CONNECTION_KEY=your_mongodb_connection_key

JWT_SALT="my-secret-key-123"

NODEMAILER_USER=your_nodemailer_user
NODEMAILER_PASSWORD=your_nodemailer_password
  1. Start the server by running npm start.

Live Link

You can access the live API at https://expense-tracker-api-3lv5.onrender.com/api/users.

API Endpoints

User Routes

  • 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"
}

Protected Routes (Require Authentication)

  • GET /api/users/dashboard: Get user dashboard information.

Transaction Routes

Protected Routes (Require Authentication)

  • 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"
}

Postman

Set the Environment Variables:

Tests Config for register and login routes:

  • This is for automating the Access Token...
pm.environment.set("accessToken", pm.response.json().accessToken)

Authors

Acknowledgements

Contact

For any questions or feedback, please feel free to reach out to me at adiyambaojs@gmail.com.

About

This API ensures a secure and reliable backend for handling expenses and transactions. It includes protected routes, requiring authentication to restrict access to authorized users for sensitive data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published