This repository contains RESTful API, web app GUI, and a CLI in plain Node JS (ES6 Javascript) with no NPM or 3rd-party libraries.
Build an API for a pizza-delivery company.
Here's the spec from your project manager:
- 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.
- Users can log in and log out by creating or destroying a token.
- 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).
- A logged-in user should be able to fill a shopping cart with menu items
- 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.
- 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 (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.
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:
- SignUp on the site.
- View all the items available to order.
- Fill up a shopping cart.
- Place an order (with fake credit card credentials), and receive an email receipt
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:
- View all the current menu items.
- View all the recent orders in the system (orders placed in the last 24 hours).
- Lookup the details of a specific order by order ID.
- View all the users who have signed up in the last 24 hours.
- Lookup the details of a specific user by email address.
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.
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
-----------------------------------------------------------------------------------------------------------
The following paths are available for the user in browser after launching the app.
Path: http://localhost:3000/
Path: http://localhost:3000/user/session/create
Path: http://localhost:3000/menu/list
Path: http://localhost:3000/user/cart/read
Path: http://localhost:3000/user/order/create
Path: http://localhost:3000/user/order/success
Path: http://localhost:3000/user/account/edit
The following endpoints are available from API perspective.
Request example:
curl -X GET http://localhost:3000/ping
Request example:
curl -X POST \
http://localhost:3000/users \
-d '{
"name": "John",
"email": "any@email.com",
"password": "1111",
"address": "San Francisco, CA",
"streetAddress": "Sunset blvd, 15"
}'
Request example:
curl -X GET \
'http://localhost:3000/users?email=any@email.com' \
-H 'token: 48df0wibmpqz69rzgb5y'
Request example:
curl -X PUT \
http://localhost:3000/users \
-H 'Content-Type: application/json' \
-H 'token: 48df0wibmpqz69rzgb5y' \
-d '{
"name": "Bill",
"email": "any@email.com"
}'
Request example:
curl -X DELETE \
'http://localhost:3000/users?email=any@email.com' \
-H 'token: b3xg95c3wp0ol1pk46vm'
Request example:
curl -X POST \
http://localhost:3000/tokens \
-d '{
"email": "any@email.com",
"password": "1111"
}'
Request example:
curl -X GET 'http://localhost:3000/tokens?id=gjfek6ha08p2x8877mno'
Request example:
curl -X PUT \
http://localhost:3000/tokens \
-H 'Content-Type: application/json' \
-d '{
"id": "gjfek6ha08p2x8877mno"
}'
Request example:
curl -X DELETE 'http://localhost:3000/tokens?id=bivegzlqhs1z5q4np0yo'
Request example:
curl -X GET \
http://localhost:3000/menus \
-H 'token: 3c3nld8owylf927r5txu'
Request example:
http://localhost:3000/carts \
-H 'token: ket278eemafcehh9vq30'
Request example:
curl -X GET \
http://localhost:3000/carts \
-H 'token: ket278eemafcehh9vq30'
Request example:
curl -X DELETE \
http://localhost:3000/carts \
-H 'token: ket278eemafcehh9vq30'
Request example:
curl -X PUT \
http://localhost:3000/carts \
-H 'Content-Type: application/json' \
-H 'token: sdvr4w4e85gw8slgycnt' \
-d '{
"id": 4,
"quantity": 2
}
'
Request example:
curl -X POST \
http://localhost:3000/orders \
-H 'Content-Type: application/json' \
-H 'token: 8l06rtpic4y4kps54pe4' \
-d '{
"paymentSource": "tok_mastercard"
}'
Request example:
curl -X GET \
'http://localhost:3000/orders?id=un2yhgqoajzmv76fozkd' \
-H 'token: 4dpj97yqr53druol20ru'