Giter VIP home page Giter VIP logo

node-natours's Introduction

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.

node-natours's People

Contributors

nolzart avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.