Wanderlust is a REST API built using Node.js, Express, and MongoDB. It provides endpoints for managing travel listings, offering core functionalities like creating, reading, updating, and deleting listings. This API serves as the backend service for a travel-themed application, enabling users to explore and manage travel destinations efficiently.
- CRUD Operations:
- Retrieve all travel listings or specific ones.
- Create new travel destinations with metadata like price, location, and images.
- Update existing travel entries dynamically.
- Delete outdated or unwanted listings.
- Optimized Query Handling: Efficiently retrieves data using MongoDB’s indexing.
- Secure: Input validation and middleware for error handling.
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose
- Authentication (Optional): Passport.js (can be integrated for secure user access)
- Environment Configuration: dotenv
- Node.js (v14 or later)
- MongoDB (Local/Cloud URI)
- npm (Node Package Manager)
-
Clone the repository:
git clone https://github.com/yourusername/wanderlust-api.git cd wanderlust-api
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and configure the MongoDB URI:MONGODB_URI=mongodb://localhost:27017/wanderlust
-
Start the server:
npm start
-
Access the API at
http://localhost:3000
.
- URL:
/listings
- Method:
GET
- Success Response:
- Code: 200
- Content:
[ { "_id": "64b12f1...", "title": "Beach House", "description": "Ocean view property.", "price": 150, "location": "Malibu", "country": "USA", "image": "url-to-image" }, ... ]
- URL:
/listings
- Method:
POST
- Body:
{ "title": "Amazing Beach House", "description": "A lovely beach house with ocean views.", "price": 150, "location": "Malibu", "country": "USA", "image": "url-to-image" }
- Success Response:
- Code: 201
- Content:
{ new listing }
- URL:
/listings/:id
- Method:
GET
- Success Response:
- Code: 200
- Content:
{ listing }
- URL:
/listings/:id
- Method:
PUT
- Body:
{ "title": "Updated Title", "description": "Updated Description", "price": 200, "location": "Updated Location", "country": "Updated Country", "image": "updated-url-to-image" }
- Success Response:
- Code: 200
- Content:
{ updated listing }
- URL:
/listings/:id
- Method:
DELETE
- Success Response:
- Code: 204
- Content:
No Content
- Cloud Deployment: The backend is deployed on Render, and the frontend is hosted on Vercel.
- Database Management: MongoDB is used as the primary database, providing scalability for large datasets.
- Middleware Integration:
- Middleware ensures data validation for every request to maintain data integrity.
- Error-handling middleware provides meaningful API responses for better debugging.
- Payment Integration (Optional): Can integrate with payment gateways like Razorpay or Stripe to enable transactions for travel bookings.
wanderlust-api/
├── models/
│ └── Listing.js # Mongoose schema for travel listings
├── routes/
│ └── listings.js # RESTful routes for travel listings
├── server.js # Entry point of the application
├── .env # Environment variables
├── package.json # Dependencies and scripts
├── README.md # Documentation
- Add user authentication for managing user-specific listings. (done)
- Implement real-time updates with WebSockets for collaborative trip planning.
- Integrate a payment gateway for secure booking transactions. (done)
- Enhance search functionality with Geo-Location APIs for nearby recommendations. (done)