Welcome to the DeeTours API! This project is a full-stack web application for managing and booking tours, built with Node.js, Express, and MongoDB.
For a comprehensive overview of all available endpoints and detailed documentation, please visit our Postman collection:
DeeTours is a comprehensive tour management platform that allows users to browse and book tours, while administrators can manage tours, bookings, and user information. This project is designed to showcase modern back-end development using Node.js and related technologies.
- Full CRUD functionality for tours, bookings, and users
- RESTful API design
- User authentication and authorization with JWT
- Data validation and error handling
- File uploads and image processing
- Secure payments with Stripe
- Deployment ready with Heroku
To get a local copy up and running, follow these steps:
- Node.js installed on your machine
- MongoDB database (local or cloud-based like MongoDB Atlas)
- Git installed on your machine
-
Clone the repository:
git clone https://github.com/DK8-PRG/DeeTours.git
-
Navigate to the project directory:
cd DeeTours
-
Install the necessary dependencies:
npm install
-
Create a .env file in the root directory and add the following variables:
Copy code PORT=5000 MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret JWT_EXPIRES_IN=90d JWT_COOKIE_EXPIRES_IN=90
Replace your_mongodb_connection_string with your actual MongoDB connection string, and your_jwt_secret with a secure JWT secret.
-
Start the development server:
npm run dev
Get All Tours
- Endpoint:
GET /api/v1/tours
- Description: Retrieve a list of all available tours.
Get Tour by ID
- Endpoint:
GET /api/v1/tours/:id
- Description: Retrieve details of a specific tour by its ID.
Create New Tour
- Endpoint:
POST /api/v1/tours
- Description: Create a new tour.
Update Tour
- Endpoint:
PATCH /api/v1/tours/:id
- Description: Update details of an existing tour by its ID.
Delete Tour
- Endpoint:
DELETE /api/v1/tours/:id
- Description: Delete a specific tour by its ID.
Get Top 5 Cheap Tours
- Endpoint:
GET /api/v1/tours/top-5-cheap
- Description: Retrieve the top 5 cheapest tours.
Get Monthly Plan
- Endpoint:
GET /api/v1/tours/monthly-plan
- Description: Retrieve the monthly plan for tours.
Get Tour Statistics
- Endpoint:
GET /api/v1/tours/statistics
- Description: Retrieve statistical data for tours.
Get Tours Within Radius
- Endpoint:
GET /api/v1/tours/within/:distance/center/:latlng/unit/:unit
- Description: Retrieve tours within a specified radius from a given point.
Get Distances to Tour from Point
- Endpoint:
GET /api/v1/tours/distances/:latlng/unit/:unit
- Description: Calculate distances to tours from a specified point.
Get All Reviews
- Endpoint:
GET /api/v1/reviews
- Description: Retrieve all reviews.
Get Review by ID
- Endpoint:
GET /api/v1/reviews/:id
- Description: Retrieve a specific review by its ID.
Create Review
- Endpoint:
POST /api/v1/reviews
- Description: Create a new review.
Update Review
- Endpoint:
PATCH /api/v1/reviews/:id
- Description: Update details of an existing review by its ID.
Delete Review
- Endpoint:
DELETE /api/v1/reviews/:id
- Description: Delete a specific review by its ID.
Create New Review for Tour
- Endpoint:
POST /api/v1/tours/:tourId/reviews
- Description: Create a new review for a specific tour.
Get Tour Reviews
- Endpoint:
GET /api/v1/tours/:tourId/reviews
- Description: Retrieve all reviews for a specific tour.
Get All Users
- Endpoint:
GET /api/v1/users
- Description: Retrieve a list of all users.
Get User by ID
- Endpoint:
GET /api/v1/users/:id
- Description: Retrieve details of a specific user by their ID.
Update User
- Endpoint:
PATCH /api/v1/users/:id
- Description: Update details of an existing user by their ID.
Delete User
- Endpoint:
DELETE /api/v1/users/:id
- Description: Delete a specific user by their ID.
Get Current User
- Endpoint:
GET /api/v1/users/me
- Description: Retrieve details of the currently authenticated user.
Update Current User
- Endpoint:
PATCH /api/v1/users/me
- Description: Update details of the currently authenticated user.
Delete Current User
- Endpoint:
DELETE /api/v1/users/me
- Description: Delete the currently authenticated user.
Sign Up
- Endpoint:
POST /api/v1/users/signup
- Description: Create a new user account.
Login
- Endpoint:
POST /api/v1/users/login
- Description: Authenticate a user and retrieve a token.
Forgot Password
- Endpoint:
POST /api/v1/users/forgotPassword
- Description: Request a password reset.
Reset Password
- Endpoint:
PATCH /api/v1/users/resetPassword/:token
- Description: Reset a user's password using a token.
Update Password
- Endpoint:
PATCH /api/v1/users/updateMyPassword
- Description: Update the password of the currently authenticated user.
Get All Bookings
- Endpoint:
GET /api/v1/bookings
- Description: Retrieve all bookings.
Get Booking by ID
- Endpoint:
GET /api/v1/bookings/:id
- Description: Retrieve details of a specific booking by its ID.
Create Booking
- Endpoint:
POST /api/v1/bookings
- Description: Create a new booking.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Duong K. Hoang - duongk.hoang@gmail.com
Project Link: https://github.com/DK8-PRG/DeeTours