Giter Club home page Giter Club logo

onshop's People

Contributors

abdallah0100 avatar hibaabid avatar moamenjs avatar

Forkers

im-ghost

onshop's Issues

.env file in the project's repo

the .env file is supposed to be a secret file, a file which contains settings for an environment but also sensitive details (in the future it might contain passwords and access to APIs which cost money)

to hide it you might need to do the following:

  • Copy the contents of the file
  • Delete the file
  • git add & commit the file change
  • then add the file to the .gitignore file

Missing relationship table

onShop/database/init.sql

Lines 11 to 22 in 16d1134

CREATE TABLE products(
id SERIAL PRIMARY KEY,
product_name VARCHAR(30) NOT NULL,
price INTEGER,
quantity INTEGER
);
CREATE TABLE cart(
id SERIAL PRIMARY KEY,
product_name VARCHAR(50) NOT NULL,
userid INTEGER
);

According to the code above, theres is no way to know which products are in which cart, since a cart can have many products, and products can be ordered in many carts, so you would need a relationship table which references both primary keys.

Also the userid field in the cart should be a foreign key that references the users table.

Use prettier

only seen the server.js and the code is not neat as it could be, fastest way to fix this and make life easy is to install the prettier extension on vscode (and make sure it's set to format on save), once you hit save you will see what I mean by the code being more neat ๐Ÿ˜… .

if you have any trouble getting prettier to work on your vscode ask a mentor

sql injection!

https://github.com/webAhead1/onShop/blob/master/server.js#L73

This is very dangerous because it's prone to an sql injection, I'll give an example of what is the problem.

In the following query you are a taking an email that a user has written down and adding it to the db, but what if the user is a hacker that instead of writing a valid email wrote the following 1; DROP DATABASE; --. the 1; is to stop the current command and write a new one, the new command DROP DATABASE; (this is not the correct syntax but you get the point) would delete the database and all of our tables, and then the -- would comment out the rest of the query.

refer to this workshop on how to fix this https://github.com/WebAhead/learn-node-postgres#sql-injection

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.