Repository navigation
Releases: WesloTheWeb/explorationNodeJS
Release list
2.3
Features
Users have more control over their own stores now! There is now a proper database cluster for this, as long as I have the MongoDB active and it doesn't hibernate. This is the release where parts of the app is locked behind registered users and guest accesses to the store.
- Users can add an uploaded image file to products.
- Users can now generate an invoice of their orders.
- Password recovery token granted.
Note: Mail APIs have changed and using Mailtrap. The email does not send since I do not have an active domain. But I don't intend to deploy this app and this is for demo purposes.
Dev Notes
- Restricted routes are now implemented. Users not signed in will not be able to add to the store.
- Error validation server side has been added.
This release state is just for learning purposes at this point and time. Highlight was packages such as
- nodemailer for sending emails
- bcryptjs for salting and hashing password that aids in the authentication and logging users in and out. Crucial to work with database. ByteByteGo has good diagram about how password validation works to the database.
- Multer for file uploads of images and validation the mime types
- pdfKit for generating pdf
2.2.4
This is a stable release, without any changes to MongoDB database permission, that has conditional log in and log out logic of the views of what a user can do.
- Makes good use of session cookies
- Uses express-session
- Links the request of user to the user model, so for each request the data persist.
- This is before proper authentication. We are still using a set user here.
v2.2.3
This is the last version of all routes and actions (such as adding or removing from store) being available and not locked between logged users and non logged users.
v2.2.0
Very similar to v2.1.0, with the exception that this version now uses Mongoose. This is a great version for practicing Mongoose, references, and adding more features in minor updates. This is a great starting place.
v2.1.0
Significant refactoring and now the code is in MongoDb. This version exclusively uses MongoDb's driver. There is no ORM / ODM in place, and the queries exist interacting with the database.
Note: Any remnants of SQL or Sequelize have been replaced. To use this, you must create a MongoDb Atlas account and connect the database through there.
Features
- Users can create products for the shop (admin tab), delete products (admin tab) and edit products.
- Users can add products to the cart, as well as remove products from the cart.
- Upon adding to cart, you can submit an order and the 'Orders' tab is now populated with a user id and items that have been purchased.
Set Up
- In order to set up, create a mongodb Atlas account, have your database config file similar to this (your own key is required)
- MongoDB Compass is optional, as it provides a GUI to see the data more clearly but you can see it in terminal. You do not need to worry about creating databases on the GUI or terminal because the code will create it as it sees fit right now with the existing queries. You will just need mainly a user with read / write access.
require('dotenv').config();
const mongodb = require('mongodb');
const MongoClient = mongodb.MongoClient;
const MongoDBPassword = process.env.DB_PASSWORD;
let _db;
const mongoConnect = (callback) => {
MongoClient.connect(`mongodb+srv://<UserId>:${MongoDBPassword}@cluster0.k30d4tr.mongodb.net/shop?retryWrites=true&w=majority`)
.then((client) => {
console.log('Connection Successful!');
_db = client.db();
callback()
})
.catch(err => {
console.log(err);
throw err;
});
};
const getDb = () => {
if (_db) {
return _db;
};
throw 'No database found!';
};
exports.mongoConnect = mongoConnect;
exports.getDb = getDb;As well as setting up the right middleware in App.js similar to this snippet
const mongoConnect = require('./util/database').mongoConnect;
...
mongoConnect(() => {
app.listen(3000);
});v2.0.7
Important
- To use this you need to Install MySQL Community Edition, MySQL Workbench and select the first authentication option, along with credentials of your admin root password in the app.
This is purely a MySQL / Sequelize version. Be sure to run npm install to install the correct dependencies. Here in this version everything is read and written over the local SQL database
Features
- Users can read data from the database
- Users can create an item and add to cart
- Users can delete item
- Users can press order now, and view orders, which place everything from the cart.
Developer
This version uses the ORM sequelize heavily along with associations. If you are looking for a refresher or want to add more, this is the version and anything between 2.0 - 2.1. As 2.1, will be switching to a NoSQL / MongoDB database,
v2.0.1
This is the start of MySQL integration.
IMPORTANT
- To use this version the pre-reqs is installing MySQL Server & Workbench 8.32+.
- During installation choose the first option of authentication not the legacy option.
- Create a table for products.
- Provide a environment variable in your code editof for the password (It's also good practice!).
- The SQL database is local. Meaning it pulls from your local machine.
Features
- Reading products from the SQL database.
- Adding products to the SQL database.
- Reading specific product from the SQL database.
- This features raw SQL injection code.
Developer Notes
- The next version will use the ORM, Sequelize but I wanted to preserve a way of just beginning SQL in the code since the next version the product created in workbench will be deleted.
- This is more for preservation at this point in time and a starting point should we need to revert or refactor or play around with just SQL code injections, then this version is the one you want.
v2.0
This is fully functional app with routing completed. Everything is open and no authentication. Files are being written and read from the JSON data, which acts as a pseudo database that is local for testing purposes.
Features
- Users can create a product to add to shop (admin).
- Users can delete a product from the shop and will be reflected on changes if any exist in the cart (admin).
- Users can edit a product in the shop (admin).
- Users can see more details.
- Users can add to cart.
- Users can see the cart and delete from shop.
Developer
- A lot of callback functions and route and flow using MVC is present.
- Note: It is a good standard to see the callback functions. This is how "state" is formed in vanilla JS. This just a has templating engine of EJS installed with some logic.
- A good reference point in this point in time.
v1.0.8
Navigation has been expanded upon.
- More server side logic has been updated, including future endpoints.
- Form now has additional fields.
- Admin view is more explicit.
- Content is now more dynamic.
- Deleted unused files leftovers.
v1.0.5
This is the last version that will hold a reference to the three templating languages.
This version contains:
- MVC set up.
- Input only for the title element of book.