/api
Authentication is handled using a JWT stored in an HTTP-only cookie named token.
Base Route:
/api/auth
POST /register
{
"name": "John Doe",
"email": "john@example.com",
"password": "securepassword123"
}{
"success": true,
"user": {
"id": "...",
"name": "John Doe",
"email": "john@example.com"
}
}Creates a new account, hashes the password, stores the user, and issues a JWT cookie.
POST /login
{
"email": "john@example.com",
"password": "securepassword123"
}Authenticates the user and issues a JWT cookie.
POST /logout
Clears the authentication cookie.
GET /me
Requires authentication.
{
"success": true,
"user": {
"id": "...",
"name": "John Doe",
"email": "john@example.com",
"balance": 1000
}
}POST /forgot-password
{
"email": "john@example.com"
}Generates a password reset token and sends a reset email.
POST /reset-password/:token
{
"password": "newpassword123"
}Updates the password and creates a new authenticated session.
Base Route:
/api/wallet
Demo Mode: Wallet endpoints may use a demo account when no authenticated user is available.
GET /user
{
"name": "Demo User",
"email": "demo@garudapay.com",
"walletBalance": 1000,
"walletStatus": "Active"
}GET /balance
{
"balance": 1000
}POST /topup
{
"amount": 250,
"method": "Card"
}Adds funds to the wallet and records a transaction.
POST /transfer
{
"amount": 100,
"recipient": "Jane Doe"
}Transfers funds and creates a debit transaction record.
GET /summary
Returns recent wallet activity.
[
{
"title": "UPI Transfer to Jane Doe",
"amount": -100,
"date": "2026-06-16 21:47",
"transactionId": "GP-TX-4839"
}
]Base Route:
/api/transaction
All routes require authentication.
GET /history
| Parameter | Description |
|---|---|
| page | Page number |
| limit | Records per page (max 50) |
| type | credit / debit |
| status | pending / completed / failed |
| from | Start date |
| to | End date |
| search | Search description |
{
"success": true,
"data": [],
"pagination": {
"currentPage": 1,
"totalPages": 3,
"totalCount": 24,
"limit": 10
}
}GET /:id
Returns transaction details if the authenticated user is involved in the transaction.
200 OK403 Forbidden404 Not Found
GET /export
Exports filtered transaction history as a CSV file.
Supports the same filtering options as /history.
- Register or Login.
- Server issues JWT in HTTP-only cookie.
- Protected routes validate the cookie using middleware.
- Logout clears the cookie.
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT Authentication
- bcryptjs
- Nodemailer
src/
├── controllers/
│ ├── auth.controller.js
│ ├── wallet.controller.js
│ └── transaction.controller.js
│
├── routes/
│ ├── auth.routes.js
│ ├── wallet.routes.js
│ └── transaction.routes.js
│
├── middleware/
│ └── auth.middleware.js
│
└── server.js