Natours is a tour booking web application designed to provide users with a seamless experience in exploring and booking various tours. Built with Node.js, Express, MongoDB, and Mongoose, it offers robust functionality and performance while following the MVC (Model-View-Controller) architecture for better structure and maintainability.
-
User Authentication and Authorization: Secure sign-up, login, and role-based access control.
-
Tour Management: Browse, search, and book tours with detailed information and pricing.
-
Booking System: Integrated booking process with payment handling via Stripe.
-
User Profiles: Manage personal information, view booking history, and update settings.
-
Secure API: Implemented best security practices to protect user data.
- Backend: Node.js, Express.js
- Database: MongoDB, Mongoose
- Architecture: MVC (Model-View-Controller) pattern
- Templating Engine: Pug
- Payment Processing: Stripe
- Authentication: JSON Web Tokens (JWT), bcrypt
- Email Service: Nodemailer, SendGrid
- Security: Helmet, xss-clean, express-rate-limit, mongo-sanitize
- File Uploads: Multer, Sharp
-
Clone the repository: git clone https://github.com/yordan-gergov01/Natours.git cd Natours
-
Install Dependencies: npm install
-
Environment Variables: Create a .env file in the root directory and add the following:
NODE_ENV=development
PORT=3000
DATABASE=Your MongoDB connection string
DATABASE_PASSWORD=Your MongoDB password
JWT_SECRET=Your JWT Secret
JWT_EXPIRES_IN=90d
JWT_COOKIE_EXPIRES_IN=90
EMAIL_USERNAME=Your Email username
EMAIL_PASSWORD=Your Email password
EMAIL_HOST=Your Email host
EMAIL_PORT=Your Email port
STRIPE_SECRET_KEY=Your Stripe secret key
STRIPE_WEBHOOK_SECRET=Your Stripe webhook secret
- Start the application
API Endpoints
Tours:
- GET /api/v1/tours: Retrieve all tours
- GET /api/v1/tours/:id: Retrieve a specific tour
- POST /api/v1/tours: Create a new tour
- PATCH /api/v1/tours/:id: Update an existing tour
- DELETE /api/v1/tours/:id: Delete a tour
Users:
- POST /api/v1/users/signup: User registration
- POST /api/v1/users/login: User login
- GET /api/v1/users/logout: User logout
- GET /api/v1/users/me: Retrieve logged-in user's profile
- PATCH /api/v1/users/updateMe: Update logged-in user's profile
- DELETE /api/v1/users/deleteMe: Deactivate logged-in user's account
Bookings:
- GET /api/v1/bookings: Retrieve all bookings
- GET /api/v1/bookings/:id: Retrieve a specific booking
- POST /api/v1/bookings: Create a new booking
- PATCH /api/v1/bookings/:id: Update an existing booking
- DELETE /api/v1/bookings/:id: Delete a booking