{"id":15630280,"url":"https://github.com/trekhleb/nodejs-master-class","last_synced_at":"2025-10-30T18:55:19.295Z","repository":{"id":43676198,"uuid":"152668998","full_name":"trekhleb/nodejs-master-class","owner":"trekhleb","description":"🛠 This repository contains the homework assignment for Node.js Master Class that is focused on building a RESTful API, web app GUI, and a CLI in plain Node JS with no NPM or 3rd-party libraries","archived":false,"fork":false,"pushed_at":"2020-12-30T11:45:20.000Z","size":5388,"stargazers_count":240,"open_issues_count":0,"forks_count":82,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-13T04:13:30.991Z","etag":null,"topics":["cli","javascript","node","node-js","nodejs","restful","restful-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trekhleb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-11T23:47:31.000Z","updated_at":"2025-02-19T17:34:00.000Z","dependencies_parsed_at":"2022-09-01T16:04:07.876Z","dependency_job_id":null,"html_url":"https://github.com/trekhleb/nodejs-master-class","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/trekhleb/nodejs-master-class","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fnodejs-master-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fnodejs-master-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fnodejs-master-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fnodejs-master-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trekhleb","download_url":"https://codeload.github.com/trekhleb/nodejs-master-class/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fnodejs-master-class/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281862825,"owners_count":26574710,"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-30T02:00:06.501Z","response_time":61,"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":["cli","javascript","node","node-js","nodejs","restful","restful-api"],"created_at":"2024-10-03T10:31:16.297Z","updated_at":"2025-10-30T18:55:19.279Z","avatar_url":"https://github.com/trekhleb.png","language":"JavaScript","readme":"# Node.js Masterclass Homework Assignment\n\nThis repository contains the homework assignment for [Node.js Master Class](https://pirple.thinkific.com/courses/the-nodejs-master-class) by [Pirple](https://pirple.thinkific.com/) that is focused on building a RESTful API, web app GUI, and a CLI in plain Node JS (ES6 Javascript) with **no NPM or 3rd-party libraries**.\n\n![](/src/assets/images/screenshots/nodejs-logo.png)\n\n## Homework Assignments\n\n### Assignment #1: Backend\n\nYou are building the API for a **pizza-delivery company**.\n\nHere's the spec from your project manager: \n\n1. **New users** can be created, their information can be edited, and they can be deleted. We should store their *name*, *email address*, and *street address*.\n2. Users can **log in** and **log out** by creating or destroying a token.\n3. When a user is logged in, they should be able to **GET all the possible menu items** (these items can be hardcoded into the system). \n4. A logged-in user should be able to **fill a shopping cart with menu items**\n5. A logged-in user should be able to **create an order**. You should integrate with the Sandbox of [Stripe.com](https://stripe.com/) to accept their payment. _Note:_ Use the stripe sandbox for your testing. [Follow this link](https://stripe.com/docs/testing#cards) and click on the \"tokens\" tab to see the fake tokens you can use server-side to confirm the integration is working.\n6. When an order is placed, you should **email the user a receipt**. You should integrate with the sandbox of [Mailgun.com](https://www.mailgun.com/) for this. _Note:_ Every Mailgun account comes with a sandbox email account domain (whatever@sandbox123.mailgun.org) that you can send from by default. So, there's no need to setup any DNS for your domain for this task. [Read more here](https://documentation.mailgun.com/en/latest/faqs.html#how-do-i-pick-a-domain-name-for-my-mailgun-account).\n\n### Assignment #2: Frontend\n\nIt is time to build a **simple frontend** for the Pizza-Delivery API you created in Homework Assignment #2. Please create a web app that allows customers to:\n\n1. **SignUp** on the site.\n2. **View all the items** available to order.\n3. **Fill up a shopping cart**.\n4. **Place an order** (with [fake credit card credentials](https://stripe.com/docs/testing#cards)), and receive an email receipt\n\n### Assignment #3: Admin CLI\n\nIt is time to build the **Admin CLI** for the pizza-delivery app you built in the previous assignments. Please build a CLI interface that would allow the manager of the pizza place to:\n\n1. View all the **current menu items**.\n2. View all the **recent orders** in the system (orders placed in the last 24 hours).\n3. Lookup the **details of a specific order** by order ID.\n4. View all the **users** who have signed up in the last 24 hours.\n5. Lookup the details of a **specific user** by email address.\n\n## The Solution\n\n### Launching the Server\n\nToo launch the application please run the following command from the project root folder:\n\n```bash\nnode index.js\n```\n\nYou may also run the application in debugging mode:\n\n```bash\nenv NODE_DEBUG=server,stripe,mailgun,cli,workers node index.js\n```\n\nRunning the APP for different environments:\n\n```bash\nNODE_ENV=staging node index.js\n```\n\nThe APP is currently supporting `staging` (default) and `production` environments.\n\n### CLI Commands\n\nThe following CLI command are available for the execution:\n\n```Text\n-----------------------------------------------------------------------------------------------------------\n                               CLI Manual\n-----------------------------------------------------------------------------------------------------------\n\nexit                           Kill the CLI (and the rest of the application)\n\nman                            Show this help page\n\nhelp                           Alis of the \"man\" command\n\nmenus                          Show the list of available menu items (pizzas)\n\norders                         View all the recent orders in the system (orders placed in the last 24 hours)\n\norder --{orderId}              Lookup the details of a specific order by order ID\n\nusers                          View all the users who have signed up in the last 24 hours\n\nuser --{email}                 Lookup the details of a specific user by email address\n\n-----------------------------------------------------------------------------------------------------------\n```\n\n### Front-End\n\nThe following paths are available for the user in browser after launching the app.\n\n#### Index Page\n\nPath: `http://localhost:3000/`\n\n![](/src/assets/images/screenshots/01-index.png)\n\n#### Login Page\n\nPath: `http://localhost:3000/user/session/create`\n\n![](/src/assets/images/screenshots/02-login.png)\n\n#### Menu List\n\nPath: `http://localhost:3000/menu/list`\n\n![](/src/assets/images/screenshots/03-menu.png)\n\n#### Shopping Cart\n\nPath: `http://localhost:3000/user/cart/read`\n\n![](/src/assets/images/screenshots/04-cart.png)\n\n#### Checkout Page\n\nPath: `http://localhost:3000/user/order/create`\n\n![](/src/assets/images/screenshots/05-checkout.png)\n\n#### Checkout Success Page\n\nPath: `http://localhost:3000/user/order/success`\n\n![](/src/assets/images/screenshots/06-success.png)\n\n#### User Profile Page\n\nPath: `http://localhost:3000/user/account/edit`\n\n![](/src/assets/images/screenshots/07-profile.png)\n\n### Back-End (API)\n\nThe following endpoints are available from API perspective.\n\n#### HealthCheck Endpoint\n\nRequest example:\n\n```bash\ncurl -X GET http://localhost:3000/ping\n```\n\n#### User Endpoints\n\n##### Create the User\n\nRequest example:\n\n```bash\ncurl -X POST \\\n  http://localhost:3000/users \\\n  -d '{\n\t\"name\": \"John\",\n\t\"email\": \"any@email.com\",\n\t\"password\": \"1111\",\n\t\"address\": \"San Francisco, CA\",\n\t\"streetAddress\": \"Sunset blvd, 15\"\n}'\n```\n\n##### Read the User\n\nRequest example:\n\n```bash\ncurl -X GET \\\n  'http://localhost:3000/users?email=any@email.com' \\\n  -H 'token: 48df0wibmpqz69rzgb5y'\n```\n\n##### Update the User\n\nRequest example:\n\n```bash\ncurl -X PUT \\\n  http://localhost:3000/users \\\n  -H 'Content-Type: application/json' \\\n  -H 'token: 48df0wibmpqz69rzgb5y' \\\n  -d '{\n\t\"name\": \"Bill\",\n\t\"email\": \"any@email.com\"\n}'\n```\n\n##### Delete the User\n\nRequest example:\n\n```bash\ncurl -X DELETE \\\n  'http://localhost:3000/users?email=any@email.com' \\\n  -H 'token: b3xg95c3wp0ol1pk46vm'\n```\n\n#### Token Endpoints\n\n##### Create the Token\n\nRequest example:\n\n```bash\ncurl -X POST \\\n  http://localhost:3000/tokens \\\n  -d '{\n\t\"email\": \"any@email.com\",\n\t\"password\": \"1111\"\n}'\n```\n\n##### Read the Token\n\nRequest example:\n\n```bash\ncurl -X GET 'http://localhost:3000/tokens?id=gjfek6ha08p2x8877mno'\n```\n\n##### Update (Prolong) the Token\n\nRequest example:\n\n```bash\ncurl -X PUT \\\n  http://localhost:3000/tokens \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n\t\"id\": \"gjfek6ha08p2x8877mno\"\n}'\n```\n\n##### Delete the Token\n\nRequest example:\n\n```bash\ncurl -X DELETE 'http://localhost:3000/tokens?id=bivegzlqhs1z5q4np0yo'\n```\n\n#### Menu Endpoint\n\n##### Get the Menu\n\nRequest example:\n\n```bash\ncurl -X GET \\\n  http://localhost:3000/menus \\\n  -H 'token: 3c3nld8owylf927r5txu'\n```\n\n#### Shopping Cart Endpoint\n\n##### Create Shopping Cart\n\nRequest example:\n\n```bash\n  http://localhost:3000/carts \\\n  -H 'token: ket278eemafcehh9vq30'\n```\n\n##### Read Shopping Cart\n\nRequest example:\n\n```bash\ncurl -X GET \\\n  http://localhost:3000/carts \\\n  -H 'token: ket278eemafcehh9vq30'\n```\n\n##### Delete Shopping Cart\n\nRequest example:\n\n```bash\ncurl -X DELETE \\\n  http://localhost:3000/carts \\\n  -H 'token: ket278eemafcehh9vq30'\n```\n\n#### Update Items in Shopping Cart\n\nRequest example:\n\n```bash\ncurl -X PUT \\\n  http://localhost:3000/carts \\\n  -H 'Content-Type: application/json' \\\n  -H 'token: sdvr4w4e85gw8slgycnt' \\\n  -d '{\n\t\"id\": 4,\n\t\"quantity\": 2\n}\n'\n```\n\n#### Order Endpoint\n\n##### Create the Order\n\nRequest example:\n\n```bash\ncurl -X POST \\\n  http://localhost:3000/orders \\\n  -H 'Content-Type: application/json' \\\n  -H 'token: 8l06rtpic4y4kps54pe4' \\\n  -d '{\n\t\"paymentSource\": \"tok_mastercard\"\n}'\n```\n\n##### Read the Order\n\nRequest example:\n\n```bash\ncurl -X GET \\\n  'http://localhost:3000/orders?id=un2yhgqoajzmv76fozkd' \\\n  -H 'token: 4dpj97yqr53druol20ru'\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrekhleb%2Fnodejs-master-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrekhleb%2Fnodejs-master-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrekhleb%2Fnodejs-master-class/lists"}