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.