A page for a travel agency startup built on top of NodeJS and NextJS, here is the live version
- Description
- Few Requirements
- Key Features
- How To Use
- API Usage
- Enviroment Variables
- Build With
- Acknowledgement
Natours is an application where the API is built with NodeJS and express. the frontend created in Nextjs is served by node. Once you enter the main page, all the tours available in the application will be displayed, each tour has a button that guides you to the details section, in this you can see all the information related to the tour, such as the routes to follow with mapboxgl and user reviews, at the end you will find a section to buy the tour with your credit card using stripejs checkout, to access the application you can use the route /login or /signup. All authentication and authorization is handled with JWT and cookies.
- Authentication and Authorization
- Sign up, Log in and Log out
- Tour
- See tour guides, check the tour route with maps, check user reviews, ratings and book the tour
- User Profile
- Update username, photo, email and password
- Credit card payment
- Log in to the site.
- Choose the tour you like the most.
- Book a tour.
- You will be redirected to the payment page.
- Enter the card details (Stripe is in test mode).
- Card No: 4242 4242 4242 4242 - Expiry date: 02 / 24 - CVV: 222
- On the account settings page, you will find a button in the "Manage Booking" navigation that will show you the tours you have booked.
- On the account settings page, you can update your own username, profile photo, email and password.
Before using the API, you need to set the variables in your API testing (like Postman or Insomnia) depending on your enviroment.
- {{URL}} with your hostname as value (Eg. http://127.0.0.1:3000 or https://www.production.com) - {{JWT}} with your Json Web Token as value.
Filtering 👉 You can include filters in the URL by including additional query parameters. To start filtering add a ?
followed by the query [query]=[value]
. If you want to chain several queries in the same call, use & followed by the query.
For example/api/v1/tours?duration=7&maxGroupSize=15
You can use mongoose operators, specifying the operator you want to use encapsulation in brackets in front of the property
For Example: api/v1/tours?duration[gte]=5&price[lte]=2000
Sorting 👉 You can sort results based on a certain field using sort
parameter.
For Example: api/v1/tours?sort=price
upward
api/v1/tours?sort=-price
falling
Limit Fields 👉 You can specify which fields you want to get back in the response using the fields
parameter.
For example: api/v1/tours?fields=name
the response will return the name field.
api/v1/tours?fields=-guides
the response will not return the guides field.
Pagination 👉 You can select a certain page of the results using the limit
parameter to indicate how many results you want per page and the page
parameter to indicate the page.
For exapmle api/v1/tours?page=2&limit=3
Tours List 👉 return all tours https://mern-natours.herokuapp.com/api/v1/tours
Tour Stats 👉 returns the statistics of all tours https://mern-natours.herokuapp.com/api/v1/tours/tours-stats
Get Tours Within Radius 👉 It shows the cheapest tours and the ones that are best rated by users https://mern-natours.herokuapp.com/api/v1/tours/top-5-cheap
Get Tours Within Radius 👉 You can get tours around a certain area, specifying the coordinates (in the form of lat, lng), the distance and the unit (mi or km)
/tours-within/distance/:distance/center/:latlng/unit/:unit
👉 https://mern-natours.herokuapp.com/api/v1/tours/tours-within/distance/200/center/34.371714,%20-117.825382/unit/mi
- NODE_ENV 👉 node enviroment (development or production)
- PORT
- DATABASE 👉 Hosted database
- DATABASE_PASSWORD 👉 Hosted database password
- JWT_SECRET 👉 Generate your secret jwt key
- JWT_EXPIRES_IN 👉 expiration time of jwt
- JWT_COOKIE_EXPIRES_IN 👉 expiration time of cookie
- EMAIL_HOST 👉 Mailtrap host
- EMAIL_PORT 👉 Mailtrap port
- EMAIL_USERNAME 👉 Mailtrap username
- EMAIL_PASSWORD 👉 Your mailtrap password
- EMAIL_FROM 👉 receiver will see this email of admin in his email
- SENDGRID_USERNAME 👉 Sengrid username
- SENDGRID_PASSWORD 👉 Sengrid password
- SENGRID_API_KEY 👉 Your sengrid api key
- STRIPE_API_KEY 👉 Your stripe secret key
- NodeJS 👉 JS runtime enviroment
- ExpressJS 👉 Web framework for Node.js
- NextJS 👉 The react framework for production
- Redux 👉 A Predictable State Container for JS Apps
- SASS 👉 CSS extension language
- Mongoose 👉 MongoDB object modeling for node.js
- MongoDB Atlas 👉 Cloud database service
- JSON Web Token 👉 open, industry standard RFC 7519 method for representing claims securely between two parties
- Stripe 👉 Payments infrastructure for the internet
- Mailtrap & Sengrid 👉 Email Delivery Service
- Heroku 👉 Cloud platform
The API and design for this project are part of a udemy online course I did. building the frontend with nextjs is my own work 😎. Thanks to Jonas Schmedtmann for this great course.