{"id":24839689,"url":"https://github.com/steveoversea/storefront-backend","last_synced_at":"2025-03-26T05:13:15.950Z","repository":{"id":202837771,"uuid":"365952931","full_name":"SteveOverSea/Storefront-Backend","owner":"SteveOverSea","description":"Udacity Full Stack Javascript Project: PostgreSQL managed API with user authentication and JWTs.","archived":false,"fork":false,"pushed_at":"2021-05-24T11:20:14.000Z","size":217,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T06:48:55.404Z","etag":null,"topics":["jwts","nanodegree-fullstackjavascript","postgres-database"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SteveOverSea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-05-10T07:19:22.000Z","updated_at":"2024-03-28T20:07:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"1a8f5a32-d277-42f5-b005-63f12bc50a17","html_url":"https://github.com/SteveOverSea/Storefront-Backend","commit_stats":null,"previous_names":["steveoversea/storefront-backend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveOverSea%2FStorefront-Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveOverSea%2FStorefront-Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveOverSea%2FStorefront-Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveOverSea%2FStorefront-Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SteveOverSea","download_url":"https://codeload.github.com/SteveOverSea/Storefront-Backend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245591587,"owners_count":20640692,"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","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":["jwts","nanodegree-fullstackjavascript","postgres-database"],"created_at":"2025-01-31T06:48:58.204Z","updated_at":"2025-03-26T05:13:15.926Z","avatar_url":"https://github.com/SteveOverSea.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Storefront Backend Project\n\nThis project is part of the Udacity Full Stack JavaScript Nanodegree.\nThe task was to implement a API for a FrontEnd Application describend in REQUIREMENTS.md\n\nIt should showcase following functionality:\n\n- setting up postgreSQL database in Node.js\n- up/down migrations with db-migrate\n- handling the structure between database models, route handlers and http verbs\n- follwing a test driven development approach with jasmine and supertest\n- password hashin with bcrypt\n- json web tokens for protecting routes (JWT)\n\n## Setup\n\n### PostgreSQL\n\nMake sure that you habe PostgreSQL installed, otherwise install [PostgreSQL](https://www.postgresql.org) from their homepage.\n\n```\npostgres --version\n```\n\nStart Postgres with\n\n```\n(sudo) su - postgres\n```\n\nand enter the Postgres terminal with\n\n```\npsql postgres\n```\n\n(you have to enter your superuser and postgres password)\n\nCreate the database\n\n```\nCREATE DATABASE \u003cdb_name\u003e;\n```\n\nCreate a user and grant access to this database\n\n```\nCREATE USER \u003cuser_name\u003e WITH PASSWORD '\u003cpassword\u003e';\n\nGRANT ALL PRIVILEGES ON DATABASE \u003cdb_name\u003e TO \u003cuser_name\u003e;\n```\n\nConnect to the database\n\n```\n\\c \u003cdb_name\u003e\n```\n\nDisplay the tables (no relations should be found)\n\n```\n\\dt\n```\n\nNow that you can create a database and a user, you should create one database (with a user) for production and one database (with a user - you can use the same as for the dev db) for testing.\n\nThe project will work with your database if you name your environment variables in the .env file (from [dotenv](https://www.npmjs.com/package/dotenv)) accordingly:\n\n```\nDB_HOST = \"\u003cwhere you DB is hosted (for development usually localhost)\u003e\"\nDB_NAME = \"\u003cdb_name\u003e\"\nDB_USER = \"\u003cuser_name\u003e\"\nDB_PASSWORD = \"\u003cpassword\u003e\"\nTEST_DB_NAME = \"\u003cdb_name\u003e\" (for tests)\n```\n\nOther environment variables that are necessary\n\n```\nENV = \"dev\" (decided to run with dev db or test db)\nBCRYPT_PW = \"\u003cwrite some string to pepper your encryption\u003e\"\nSALT_ROUNDS = \"\u003cwrite an integer to say how many times the pw should be hashed\u003e\"\nTOKEN_SECRET = \"\u003cwrite a string for the JWT secret\u003e\"\nPROJECT_PATH = \"\u003cpath to your served project\u003e\"\n```\n\nInstall the node modules\n\n```\nnpm install\n```\n\nLoad the database schema with\n\n```\ndb-migrate up\n```\n\nRun the test suite with \n\n```\nnpm run test-up\n```\n\nand afterwards reset the test-database with\n\n```\nnpm run test-down\n```\n\nyou can start this API with\n\n```\nnpm run start\n```\n\nThe server runs on localhost:3000 on default.\n\n## Routes and Database Schemas\n\nShow and Index routes never require a token.\nCreate, Update and Delete routes usually do.\n\n### /users\n\nThe user consists out of\n- id \n- first_name\n- last_name\n- password\n- recentPurchases (optional)\n\nCreating the user doesn't need a token.\nYou can login with your credentials on /users/login\n\nThe passwords gets hashed with bcrypt.\n\nOn the Show route (GET users/:id) you also get recentPurchases back, an array of max. 5 Products the user recently ordered.\n\n### /products\n\nThe product consists out of\n- id\n- name\n- price\n- category\n\nThe usual CRUD routes are implemented, you need a user token for all manipulating routes.\n\n### /orders\n\nThe order consists out of\n- id\n- user_id\n- status\n  \nThe order stores orders connected to a specific users and saves the current status (active or finished).\nThe usual CRUD routes are implemented, you need a user token for all manipulating routes.\n\n### /order_lists\nThe order consists out of\n- id\n- order_id\n- quantity\n- product_id\n  \nThe order_lists stores the products and quantity connected to a specific order.\nThe usual CRUD routes are implemented, you need a user token for all manipulating routes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteveoversea%2Fstorefront-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteveoversea%2Fstorefront-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteveoversea%2Fstorefront-backend/lists"}