This is project to practice working with nodejs.
The project use mongodb
databases.
Saves user data in server-side session
to mongodb database.
Hides menu
items for unauthorized users
.
We store all user data in sessions
.
Encrypts the password
before saving to the database. Uses tokens
to protect data submission forms
.Displays error messages
to the user on the page.
It is possible to change the password
for a registered user.The login form has a button
to change the password
. A link
to change the password
will be sent to the email
by which the user is registered.
All input forms are validated
Uploading files
for products on the site and saving to images
folder, as well as deleting them with the product. Create an Invoice PDF file
from the shopping cart and saving to data/invoices
folder.
Pagination
for products
. Shows no more than two products on one page, scatters the rest on pages
Pay from cart
goes through the Stripe payment system.
All http requests will be saved to the access.log
file.
All settings are saved to file nodemon.json
You can find a live example of a site on heroku-exapmple if it still works of course.
- Install all packages
npm i
- Create table
shop
in mongodb before starting - Save connect settings in
nodemon.json
In the project directory, you can run:
npm run start
start project in development modenpm run start-server
start project in production mode
Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.
- bcryptjs - is a secured way to store passwords in my database regardless of whatever language my app’s backend
- body-parser - Parse incoming request bodies in a middleware before your handlers, available under the req.body property.
- compression - is a middleware will attempt to compress response bodies for all request that traverse through the middleware.
- connect-flash - is a special area of the session used for storing messages.
- connect-mongodb-session - MongoDB-backed session storage for connect and Express. Used to store sessions in MongoDB.
- csurf - is a middleware for CSRF token creation and validation.
- ejs - html template engine
- express - minimal and flexible Node.js web application framework
- express-session - The data is stored on the server, and the client-side session ID is in a cookie. Moreover,
express-session
uses thecookie-parser
by default to parsecookies
. - express-validator - is a set of express.js middlewares that wraps validator.js validator and sanitizer functions.
- helmet - secure Express apps by setting various HTTP headers
- nodemon - monitor for any changes in your source and automatically restart your server
- mongoose - is a MongoDB object modeling tool designed to work in an asynchronous environment. Mongoose supports both promises and callbacks.
- morgan - middleware for handling
multipart/form-data
, which is primarily used for uploading files - multer - HTTP request logger middleware
- nodemailer - is a module for Node.js applications to allow easy as cake email sending.
- nodemailer-sendgrid-transport - is a transport plugin for Nodemailer that makes it possible to send through SendGrid's Web API!
- pdfkit - is a PDF document generation library, makes creating complex, multi-page, printable documents easy.
- stripe - library provides convenient access to the Stripe API from applications written in server-side JavaScript.