nolzart / node-natours

A page for a travel agency startup built on top of NodeJS and NextJS.

Home Page:https://mern-natours.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Natours

A page for a travel agency startup built on top of NodeJS and NextJS, here is the live version

Description

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.

Few Requirements

Key Features

  • 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

How To Use

Book a tour

  • 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
    

Manage your booking

  • On the account settings page, you will find a button in the "Manage Booking" navigation that will show you the tours you have booked.

Update your profile

  • On the account settings page, you can update your own username, profile photo, email and password.

API usage

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.
    

API Features

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 sortparameter.

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

Enviroment Variables

Server and Database Keys

  1. NODE_ENV πŸ‘‰ node enviroment (development or production)
  2. PORT
  3. DATABASE πŸ‘‰ Hosted database
  4. DATABASE_PASSWORD πŸ‘‰ Hosted database password

Authentication Keys

  1. JWT_SECRET πŸ‘‰ Generate your secret jwt key
  2. JWT_EXPIRES_IN πŸ‘‰ expiration time of jwt
  3. JWT_COOKIE_EXPIRES_IN πŸ‘‰ expiration time of cookie

Email Keys

  1. EMAIL_HOST πŸ‘‰ Mailtrap host
  2. EMAIL_PORT πŸ‘‰ Mailtrap port
  3. EMAIL_USERNAME πŸ‘‰ Mailtrap username
  4. EMAIL_PASSWORD πŸ‘‰ Your mailtrap password

Admin details

  1. EMAIL_FROM πŸ‘‰ receiver will see this email of admin in his email
  2. SENDGRID_USERNAME πŸ‘‰ Sengrid username
  3. SENDGRID_PASSWORD πŸ‘‰ Sengrid password
  4. SENGRID_API_KEY πŸ‘‰ Your sengrid api key

Stripe Keys

  1. STRIPE_API_KEY πŸ‘‰ Your stripe secret key

Build With

  • 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

Acknowledgement

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.

About

A page for a travel agency startup built on top of NodeJS and NextJS.

https://mern-natours.herokuapp.com/


Languages

Language:JavaScript 99.6%Language:SCSS 0.2%Language:Pug 0.1%Language:HTML 0.1%Language:Shell 0.0%