2nd homework assignment for Pirple's NodeJS master class. This project is a JSON RESTful API free of 3rd-party dependencies for a pizza-delivery company utilizing Stripe and MailGun external services.
Method Header Query params Payload Desc
GET
token
* email
* Return information about the user except for password in a JSON format.
PUT
token
* email
, at least one of: (firstName
, lastName
, password
)* Change one/more of user's information. Email change not allowed.
POST
firstName
, lastName
*, email
*, password
*, streetAddress
* Create a user account.
DELETE
token
email
Delete user's account.
Method Header Query params Payload Desc
GET
id
* Get token's id and expiration date.
PUT
id
*, extend
* With extend set to true, a valid token's lifespan is extended.
POST
email
*, password
* Log in. Return a new, valid token for the user to use with other routes.
DELETE
id
* Log out.
Method Header Query params Payload Desc
GET
token
* Get menu as a JSON array of pizzas.
Method Header Query params Payload Desc
GET
token
* Get full list of existing, unpurchased orders for the user.
POST
token
* array of items*, eg. [{"id":1,"amount":2}] Save an order to the shopping cart. amount
field in the item is optional. If not supplied, it's set to 1.
DELETE
token
* orderid
* Delete an order from user's shopping cart.
Method Header Query params Payload Desc
POST
token
*, orderId
array of items, eg. [{"id":1,"amount":2}] If orderId header is set, the order is loaded from user's shopping cart. If payload is populated (just as in POST
for SHOPPINGCART
route), the order is loaded from it. If both are set, orderId precedes. If the payment is successful, a receipt is emailed.
*Required
- Download the project.
- Open the command prompt (for Windows, click Start icon and type in 'cmd') and go to the project directory.eg. :
cd C:/PIZZAAPI
- Run the app:
node index.js
Optionally, one can set the environment as command line argument (with value of 'production' or 'staging'). The default is 'staging'.node index.js production
(for Windows)NODE_ENV=production node index.js
(for Linux) - Open up a web browser or a tool like Postman or curl. Start making requests. Follow the Basic scenario below to learn the most useful requests.
- Create a user. (
USERS
,POST
) - Log in. (
TOKENS
,POST
) - View menu. (
MENU
,GET
) - Order a pizza. (
SHOPPINGCART
,POST
) - Pay for the order. (
PURCHASE
,POST
) - Check email for a receipt.
- Log out. (
TOKENS
,DELETE
)
Please populate the fields in your request according to the ROUTE tables above. Required fields are marked with *.
- Create a user (an account).
- Get user's data.
- Update user's data.
- Delete a user (an account).
- Create a token (log into an account).
- Get token's data (expiration date and time).
- Extend token's expiration date.
- Delete a token (log out).
- Get the menu.
- Create an order (select items from menu).
- List existing orders (items chosen but not yet purchased).
- Delete an order.
- Pay for an existing order.
- Send an order and pay for it all in one request.