All Projects → trekhleb → Nodejs Master Class

trekhleb / Nodejs Master Class

Licence: mit
🛠 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

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Nodejs Master Class

Nodepress
😎 RESTful API service for Blog/CMS, powered by @nestjs
Stars: ✭ 829 (+355.49%)
Mutual labels:  restful-api, restful, node-js
Restbed
Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications.
Stars: ✭ 1,551 (+752.2%)
Mutual labels:  restful-api, restful
Restful Api Guidelines
A model set of guidelines for RESTful APIs and Events, created by Zalando
Stars: ✭ 1,397 (+667.58%)
Mutual labels:  restful-api, restful
Node Express Mongoose Passport Jwt Rest Api Auth
Node, express, mongoose, passport and JWT REST API authentication example
Stars: ✭ 146 (-19.78%)
Mutual labels:  restful-api, restful
Api Restful Con Laravel Guia Definitiva
Repositorio para el código base del curso "API RESTful con Laravel - Guía Definitiva"
Stars: ✭ 95 (-47.8%)
Mutual labels:  restful-api, restful
Node Typescript Mongodb
node js typescript mongodb express generator yo
Stars: ✭ 96 (-47.25%)
Mutual labels:  restful, node-js
Codeigniter Jwt Sample
CodeIgniter JWT Sample
Stars: ✭ 144 (-20.88%)
Mutual labels:  restful-api, restful
Restfm
RESTful web services for FileMaker server.
Stars: ✭ 76 (-58.24%)
Mutual labels:  restful-api, restful
Node Express Postgresql Sequelize
Node.js, Express.js, Sequelize.js and PostgreSQL RESTful API
Stars: ✭ 148 (-18.68%)
Mutual labels:  restful-api, restful
Swagger meqa
Auto generate and run tests using swagger/OpenAPI spec, no coding needed
Stars: ✭ 151 (-17.03%)
Mutual labels:  restful-api, restful
Restful Api With Laravel Definitive Guide
Repository with the base code for the course "RESTful API with Laravel - Definitive-Guide"
Stars: ✭ 156 (-14.29%)
Mutual labels:  restful-api, restful
Forge Node App
🛠📦🎉 Generate Node.js boilerplate with optional libraries & tools
Stars: ✭ 90 (-50.55%)
Mutual labels:  cli, node-js
Swag Bot
My first ever discord bot using discord.js. The bot has a total of 77 commands, and it is capable of manipulating texts and images, analyzing data, searching information, and playing music. It has high level features like xp system, coins database, and spam detector.
Stars: ✭ 86 (-52.75%)
Mutual labels:  restful-api, node-js
Grest
Build REST APIs with Neo4j and Flask, as quickly as possible!
Stars: ✭ 102 (-43.96%)
Mutual labels:  restful-api, restful
Python Ilorest Library Old
Python library for iLO RESTful API
Stars: ✭ 85 (-53.3%)
Mutual labels:  restful-api, restful
Ssm Cluster
🍏Spring+SpringMVC+Mybatis+adminLTE3实现前后端分离(nginx负载均衡+tomcat集群)
Stars: ✭ 142 (-21.98%)
Mutual labels:  restful-api, restful
Discordrpcmaker
Cross-platform Discord Rich Presence Maker, WITH BUTTONS!
Stars: ✭ 165 (-9.34%)
Mutual labels:  cli, node-js
Lumen Api Oauth
A RESTful API based on Lumen micro-framework with OAuth2.
Stars: ✭ 73 (-59.89%)
Mutual labels:  restful-api, restful
Graceful
Elegant Python REST toolkit built on top of falcon
Stars: ✭ 73 (-59.89%)
Mutual labels:  restful-api, restful
Awesome Http Benchmark
HTTP(S) benchmark tools, testing/debugging, & restAPI (RESTful)
Stars: ✭ 2,236 (+1128.57%)
Mutual labels:  restful-api, restful

Node.js Masterclass Homework Assignment

This repository contains the homework assignment for Node.js Master Class by Pirple 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.

Homework Assignments

Assignment #1: Backend

You are building the API for a pizza-delivery company.

Here's the spec from your project manager:

  1. 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.
  2. Users can log in and log out by creating or destroying a token.
  3. 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).
  4. A logged-in user should be able to fill a shopping cart with menu items
  5. A logged-in user should be able to create an order. You should integrate with the Sandbox of Stripe.com to accept their payment. Note: Use the stripe sandbox for your testing. Follow this link and click on the "tokens" tab to see the fake tokens you can use server-side to confirm the integration is working.
  6. When an order is placed, you should email the user a receipt. You should integrate with the sandbox of Mailgun.com for this. Note: Every Mailgun account comes with a sandbox email account domain ([email protected]) 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.

Assignment #2: Frontend

It 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:

  1. SignUp on the site.
  2. View all the items available to order.
  3. Fill up a shopping cart.
  4. Place an order (with fake credit card credentials), and receive an email receipt

Assignment #3: Admin CLI

It 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:

  1. View all the current menu items.
  2. View all the recent orders in the system (orders placed in the last 24 hours).
  3. Lookup the details of a specific order by order ID.
  4. View all the users who have signed up in the last 24 hours.
  5. Lookup the details of a specific user by email address.

The Solution

Launching the Server

Too launch the application please run the following command from the project root folder:

node index.js

You may also run the application in debugging mode:

env NODE_DEBUG=server,stripe,mailgun,cli,workers node index.js

Running the APP for different environments:

NODE_ENV=staging node index.js

The APP is currently supporting staging (default) and production environments.

CLI Commands

The following CLI command are available for the execution:

-----------------------------------------------------------------------------------------------------------
                               CLI Manual
-----------------------------------------------------------------------------------------------------------

exit                           Kill the CLI (and the rest of the application)

man                            Show this help page

help                           Alis of the "man" command

menus                          Show the list of available menu items (pizzas)

orders                         View all the recent orders in the system (orders placed in the last 24 hours)

order --{orderId}              Lookup the details of a specific order by order ID

users                          View all the users who have signed up in the last 24 hours

user --{email}                 Lookup the details of a specific user by email address

-----------------------------------------------------------------------------------------------------------

Front-End

The following paths are available for the user in browser after launching the app.

Index Page

Path: http://localhost:3000/

Login Page

Path: http://localhost:3000/user/session/create

Menu List

Path: http://localhost:3000/menu/list

Shopping Cart

Path: http://localhost:3000/user/cart/read

Checkout Page

Path: http://localhost:3000/user/order/create

Checkout Success Page

Path: http://localhost:3000/user/order/success

User Profile Page

Path: http://localhost:3000/user/account/edit

Back-End (API)

The following endpoints are available from API perspective.

HealthCheck Endpoint

Request example:

curl -X GET http://localhost:3000/ping

User Endpoints

Create the User

Request example:

curl -X POST \
  http://localhost:3000/users \
  -d '{
	"name": "John",
	"email": "[email protected]",
	"password": "1111",
	"address": "San Francisco, CA",
	"streetAddress": "Sunset blvd, 15"
}'
Read the User

Request example:

curl -X GET \
  'http://localhost:3000/[email protected]' \
  -H 'token: 48df0wibmpqz69rzgb5y'
Update the User

Request example:

curl -X PUT \
  http://localhost:3000/users \
  -H 'Content-Type: application/json' \
  -H 'token: 48df0wibmpqz69rzgb5y' \
  -d '{
	"name": "Bill",
	"email": "[email protected]"
}'
Delete the User

Request example:

curl -X DELETE \
  'http://localhost:3000/[email protected]' \
  -H 'token: b3xg95c3wp0ol1pk46vm'

Token Endpoints

Create the Token

Request example:

curl -X POST \
  http://localhost:3000/tokens \
  -d '{
	"email": "[email protected]",
	"password": "1111"
}'
Read the Token

Request example:

curl -X GET 'http://localhost:3000/tokens?id=gjfek6ha08p2x8877mno'
Update (Prolong) the Token

Request example:

curl -X PUT \
  http://localhost:3000/tokens \
  -H 'Content-Type: application/json' \
  -d '{
	"id": "gjfek6ha08p2x8877mno"
}'
Delete the Token

Request example:

curl -X DELETE 'http://localhost:3000/tokens?id=bivegzlqhs1z5q4np0yo'

Menu Endpoint

Get the Menu

Request example:

curl -X GET \
  http://localhost:3000/menus \
  -H 'token: 3c3nld8owylf927r5txu'

Shopping Cart Endpoint

Create Shopping Cart

Request example:

  http://localhost:3000/carts \
  -H 'token: ket278eemafcehh9vq30'
Read Shopping Cart

Request example:

curl -X GET \
  http://localhost:3000/carts \
  -H 'token: ket278eemafcehh9vq30'
Delete Shopping Cart

Request example:

curl -X DELETE \
  http://localhost:3000/carts \
  -H 'token: ket278eemafcehh9vq30'

Update Items in Shopping Cart

Request example:

curl -X PUT \
  http://localhost:3000/carts \
  -H 'Content-Type: application/json' \
  -H 'token: sdvr4w4e85gw8slgycnt' \
  -d '{
	"id": 4,
	"quantity": 2
}
'

Order Endpoint

Create the Order

Request example:

curl -X POST \
  http://localhost:3000/orders \
  -H 'Content-Type: application/json' \
  -H 'token: 8l06rtpic4y4kps54pe4' \
  -d '{
	"paymentSource": "tok_mastercard"
}'
Read the Order

Request example:

curl -X GET \
  'http://localhost:3000/orders?id=un2yhgqoajzmv76fozkd' \
  -H 'token: 4dpj97yqr53druol20ru'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].