{"id":18895207,"url":"https://github.com/farisc0de/storefrontbackend","last_synced_at":"2025-10-14T14:34:46.261Z","repository":{"id":115935770,"uuid":"588756995","full_name":"farisc0de/StoreFrontBackend","owner":"farisc0de","description":"A Basic back-end system for an e-commerce website","archived":false,"fork":false,"pushed_at":"2023-01-13T23:15:18.000Z","size":141,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-18T23:38:16.972Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/farisc0de.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-13T23:12:54.000Z","updated_at":"2023-03-10T12:38:38.000Z","dependencies_parsed_at":"2023-03-11T22:45:58.713Z","dependency_job_id":null,"html_url":"https://github.com/farisc0de/StoreFrontBackend","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/farisc0de/StoreFrontBackend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farisc0de%2FStoreFrontBackend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farisc0de%2FStoreFrontBackend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farisc0de%2FStoreFrontBackend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farisc0de%2FStoreFrontBackend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/farisc0de","download_url":"https://codeload.github.com/farisc0de/StoreFrontBackend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farisc0de%2FStoreFrontBackend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279019126,"owners_count":26086680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T08:27:09.725Z","updated_at":"2025-10-14T14:34:46.216Z","avatar_url":"https://github.com/farisc0de.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Storefront Backend Project\n\n## Getting Started\n\nThis repo contains a basic Node and Express app to get you started in constructing an API. To get started, clone this repo and run `yarn` in your terminal at the project root.\n\n## Required Technologies\n\nYour application must make use of the following libraries:\n\n- Postgres for the database\n- Node/Express for the application logic\n- dotenv from npm for managing environment variables\n- db-migrate from npm for migrations\n- jsonwebtoken from npm for working with JWTs\n- jasmine from npm for testing\n\n## Steps to Completion\n\n### 1. Plan to Meet Requirements\n\nIn this repo there is a `REQUIREMENTS.md` document which outlines what this API needs to supply for the frontend, as well as the agreed upon data shapes to be passed between front and backend. This is much like a document you might come across in real life when building or extending an API.\n\nYour first task is to read the requirements and update the document with the following:\n\n- Determine the RESTful route for each endpoint listed. Add the RESTful route and HTTP verb to the document so that the frontend developer can begin to build their fetch requests.  \n  **Example**: A SHOW route: 'blogs/:id' [GET]\n\n- Design the Postgres database tables based off the data shape requirements. Add to the requirements document the database tables and columns being sure to mark foreign keys.  \n  **Example**: You can format this however you like but these types of information should be provided\n  Table: Books (id:varchar, title:varchar, author:varchar, published_year:varchar, publisher_id:string[foreign key to publishers table], pages:number)\n\n**NOTE** It is important to remember that there might not be a one to one ratio between data shapes and database tables. Data shapes only outline the structure of objects being passed between frontend and API, the database may need multiple tables to store a single shape.\n\n### 2. DB Creation and Migrations\n\nNow that you have the structure of the databse outlined, it is time to create the database and migrations. Add the npm packages dotenv and db-migrate that we used in the course and setup your Postgres database. If you get stuck, you can always revisit the database lesson for a reminder.\n\nYou must also ensure that any sensitive information is hashed with bcrypt. If any passwords are found in plain text in your application it will not pass.\n\n### 3. Models\n\nCreate the models for each database table. The methods in each model should map to the endpoints in `REQUIREMENTS.md`. Remember that these models should all have test suites and mocks.\n\n### 4. Express Handlers\n\nSet up the Express handlers to route incoming requests to the correct model method. Make sure that the endpoints you create match up with the enpoints listed in `REQUIREMENTS.md`. Endpoints must have tests and be CORS enabled.\n\n### 5. JWTs\n\nAdd JWT functionality as shown in the course. Make sure that JWTs are required for the routes listed in `REQUIUREMENTS.md`.\n\n### 6. QA and `README.md`\n\nBefore submitting, make sure that your project is complete with a `README.md`. Your `README.md` must include instructions for setting up and running your project including how you setup, run, and connect to your database.\n\nBefore submitting your project, spin it up and test each endpoint. If each one responds with data that matches the data shapes from the `REQUIREMENTS.md`, it is ready for submission!\n\n## How to install\n\n```\nnpm install\n```\n\n## How to run\n\n```\nnpm run dev\n```\n\n## How to Test\n\nFirst set the enviorment to test in the `.env`\n\n```\nENV=test\n```\n\nThen run the tests\n\n```\nnpm run test\n```\n\n## How to connect to the database\n\nUpdate the dotenv file with required values\n\n```\nDATABASE_HOST=localhost\nDATABASE_USER=\nDATABASE_PASS=\nDATABASE_NAME=\n```\n\nI am using the port: 5432\n\n## How to setup encryption\n\nGenerate keys from this website\n\nhttps://www.allkeysgenerator.com/Random/Security-Encryption-Key-Generator.aspx\n\nUpdate the dotenv values with the required values\n\n```\nBCRYPT_PASSWORD=\nSALT_ROUNDS=10\nTOKEN_SECRET=\n```\n\n## How to migrate database\n\n```\nnpm install -g db-migrate\n```\n\nThen\n\n```\ndb-migrate up\n```\n\nIf you want to go this way please update database.json\n\n```\n{\n    \"dev\": {\n        \"driver\": \"pg\",\n        \"host\": \"127.0.0.1\",\n        \"database\": \"storefront\",\n        \"user\": \"postgres\",\n        \"password\": \"farisksa1997\"\n    },\n    \"test\": {\n        \"driver\": \"pg\",\n        \"host\": \"127.0.0.1\",\n        \"database\": \"storefront\",\n        \"user\": \"postgres\",\n        \"password\": \"farisksa1997\"\n    }\n}\n```\n\nOr you can execute these SQL commands in your psql terminal\n\n### Create Users table\n\n```sql\nCREATE TABLE users (\n    id serial,\n    firstName varchar(255),\n    lastName varchar(255),\n    username VARCHAR(100),\n    password varchar(255),\n    PRIMARY KEY(id)\n);\n```\n\n### Create products table\n\n```sql\nCREATE TABLE products (\n    id serial,\n    name varchar(255),\n    price varchar(255),\n    category int,\n    PRIMARY KEY(id)\n);\n```\n\n### Create orders table\n\n```sql\nCREATE TABLE orders (\n    id serial,\n    user_id int,\n    status varchar(255),\n    PRIMARY KEY(id)\n);\n```\n\n### Create categories table\n\n```sql\nCREATE TABLE categories (\n    id serial,\n    name varchar(255),\n    PRIMARY KEY(id)\n);\n```\n\n### Create orders products table\n\n```sql\nCREATE TABLE orderproducts (\n    id serial,\n    order_id int not null REFERENCES orders (id) ON UPDATE CASCADE ON DELETE CASCADE,\n    product_id int not null REFERENCES products (id) ON UPDATE CASCADE ON DELETE CASCADE,\n    PRIMARY KEY (id)\n);\n```\n\n### Create your first user\n\n```sql\nINSERT INTO users (firstName, lastName, username, password) VALUES (\n    'faris',\n    'mohammed',\n    'admin',\n    '$2a$12$9g5Z7JTppRhzVPZI3NzDAeF4CJD42rO/gz9CmBjuUmADFmN0X.dMe'\n);\n\n```\n\n### Create your first category\n\n```sql\nINSERT INTO categories (name) VALUES ('car');\n```\n\n### Create your first product\n\n```sql\nINSERT INTO products (name, price, category) VALUES (\n    'Camry 2022',\n    '250000',\n    1\n);\n```\n\n### Create your first order\n\n```sql\nINSERT INTO orders (user_id, status) VALUES (1, 'active');\n```\n\n## Environment variables\n\n```\nPORT=3000\nURL=\nENV=\n\nDATABASE_HOST=localhost\nDATABASE_USER=\nDATABASE_PASS=\nDATABASE_NAME=\n\nBCRYPT_PASSWORD=\nSALT_ROUNDS=10\n\nTOKEN_SECRET=\n```\n\n## Default Username and Password\n\n- Username: faris\n- Password: faris\n\n## Routes\n\nUsers\n\n```\n(POST) /users\n(GET) /user/:id\n(GET) /user\n(POST) /login\n(POST) /register\n```\n\nOrders\n\n```\n(GET) /users/:user_id/completed\n(GET) /orders/:user_id/active\n(GET) /order/add/:product_id/:order_id\n(GET) /order/quantity/:order_id\n(POST) /orders\n```\n\nProducts\n\n```\n(POST) /products\n(GET) /products\n(GET) /product/:id\n(GET) /products/:id\n```\n\n## Data Shapes\n\n![](https://i.ibb.co/6FjRg84/image.png)\n\n## Database Scheme\n\n![](https://i.ibb.co/LSC0Z3h/Untitled.png)\n\n#### Product\n\n- id: number\n- name: string\n- price: number\n- [OPTIONAL] category: number\n\n#### User\n\n- id: number\n- firstName: string\n- lastName: string\n- password: string\n\n#### Orders\n\n- id: number\n- user_id: number\n- status of order (active or complete): string\n\n### Categories\n\n- id: number\n- name: string\n\n### OrderProducts\n\n- id: number\n- product_id: number\n- order_id: number\n\n## Copyright\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarisc0de%2Fstorefrontbackend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarisc0de%2Fstorefrontbackend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarisc0de%2Fstorefrontbackend/lists"}