Giter Site home page Giter Site logo

alexmndzf / nodejs-shop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nataliecardot/nodejs-shop

0.0 0.0 0.0 5.14 MB

Node.js/Express/MongoDB online shop with user accounts, Stripe checkout, and more

Home Page: https://suess.herokuapp.com/

JavaScript 57.03% CSS 13.61% EJS 29.36%

nodejs-shop's Introduction

nodejs-shop

Online shop built using Node.js, Express, and MongoDB/Mongoose. The user can create an account, reset their password, add and remove cart items, upload and delete products, update data for products they added, checkout their cart, place orders, and view past orders.

It follows the MVC design pattern, and renders views on the server using the EJS templating engine. The SendGrid API is used to send emails (confirmation of account creation and password reset instructions) and payments are handled using the Stripe API. Other features include pagination, error handling, validation of user input, sessions, authentication, and file storage.

Image files are hosted in an AWS S3 bucket. Uploading a new image for a product or deleting a product entirely deletes the respective image from the bucket.

Prior to the final version, I also used SQL (MySQL)/Sequelize, and output dynamic content with Pug and Handlebars. The code was refactored numerous times to try different approaches. In the course, files were uploaded using the filesystem and stored locally, but a cloud storage approach was necessary for a viable app due to the hosting provider Heroku's ephemeral filesystem.

When you place an order in the app, you'll be redirected to Stripe checkout in test mode. You can simulate a purchase using test card numbers. For a production app, live mode rather than test mode publishable and secret keys would be used.

Basic project structure/terminology notes: Middleware = methods/functions/operations that are called between processing the request and sending the response. An Express app contains multiple levels of middleware, such as application-level middleware (app.use(middleware) and router-level middleware (e.g., router.use(middleware)). app.use(middleware) is called every time a request is sent to the server. (app.get() is called when the HTTP method is set to GET, whereas app.use() is called regardless of the HTTP method.) These define a route handler file as middleware, which also contains middleware - the route files forward requests to controller "actions," methods that handle incoming requests (for example getNewPassword in controllers/auth.js).

Built as a course project for Udemy's NodeJS - The Complete Guide by Maximilian Schwarzmüller.

View Locally

  1. Install dependencies
npm install
  1. Change the filename of example-nodemon.json to nodemon.json. Use the example as a guideline to replace keys with appropriate API keys, etc., from MongoDB, SendGrid, and Stripe. These can each be acquired using a free account.

  2. Start Nodemon server at http://localhost:3000 (the start:dev script must be used since nodemon.json is used to store environment variables, and the other scripts do not use Nodemon)

npm run start:dev

nodejs-shop's People

Contributors

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