Skip to content

benjaoholeguy/PIZZA-DELIVERY-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 

Repository files navigation

PIZZA-DELIVERY-API

Explanation

  • API Implementation for a pizza-delivery company.
  • RESTful JSON API that listens on ports 3000 and 3001 for testing and 5000 and 5001 for production.
  • API allows you to:
    • Create, edit and delete users (name, email address, street address)
    • Create, edit and delete tokens
    • Get pizza's information
    • Create, edit and delete carts
    • Make payments (orders) integrated with Stripe API
    • Send confirmation Email integrated with Mailgun API
    • User could login and logout creating and destroying a token

Improvement opportunities

- Keep carts information. EG: present information about sales. Pizza array added to order. DONE (stored in order information)
- Create a worker to delete expired tokens
- Test automation 

Email validation

  • Two validation levels of the email:
    • Empty email field
    • Existence Email validation have been done with trumail API (https://trumail.io/)

Operating Instructions

Tech Stack

  • node

Third-party APIs Used


RESTful API ENDPOINTS

/pizzas

GET
  • Retrieve data for an existing user as JSON.
  • Required fields: (in queryStringObject object) {string}email, {numeric}pizzaId
  • Return: Pizza object
  • Requires Token: Yes

/orders

POST
  • Register a new json order in orders folder. Make the payment connecting with Stripe API. Delete json cart from carts folder after the payment. Send an email with the order's amount and id.
  • Required: (in JSON payload) {string}orderId, {string}email
  • Return: Order object. {string}orderId, {string}paymentId, {numeric}amount, {string}userEmail, {Date}date
  • Requires Token: Yes

/carts

POST
  • Register a new json cart in carts folder.
  • Required: (in JSON payload) {Array}pizzas, {string}email
  • Return: Cart object. {string}cartId, {Array}pizzas, {string}userEmail
  • Requires Token: Yes
GET
  • Retrieve data for an existing cart in JSON format.
  • Required fields: (in queryStringObject object) {string}id
  • Return: Cart object
  • Requires Token: Yes
PUT
  • Update an existing cart.
  • Required: (in JSON payload) {string}id, {Array}pizzas
  • Return: Cart object
  • Requires Token: Yes
DELETE
  • Delete an existing user.
  • Required: (in JSON payload) {string}id
  • Return: {}
  • Requires Token: Yes

/users

POST
  • Create a new user. Each user must have a unique email address.
  • Required: (in JSON payload) {string}name, {string}email, {string}address, {boolean}tosAgreement
  • Return: User object
  • Requires Token: No
GET
  • Retrieve data for an existing user as JSON.
  • Required fields: (in queryStringObject object) {string}email
  • Return: User object
  • Requires Token: Yes
PUT
  • Update an existing user.
  • Required: (in JSON payload) email
  • Optional: (in JSON payload) name, address, tosAgreement (at least one must be specified)
  • Return: User object
  • Requires Token: Yes
DELETE
  • Delete an existing user.
  • Required: (in JSON payload) {string}email
  • Return: {}
  • Requires Token: Yes

/tokens

POST
  • Create user token
  • Required fields: (in JSON payload) {String}email
  • Return: {String}email, {String}id, {number}expires
  • Requires Token: No
GET
  • Lookup the token for a user.
  • Required: (in queryStringObject object) {String}id
  • Return: {String}email, {String}id, {number}expires
  • Requires Token: No
PUT
  • Extend a token for a user.
  • Required: (in JSON payload) {string}id, {boolean}extend
  • Return: {}
  • Requires Token: Yes
DELETE
  • Remove user token
  • Required fields: (in queryStringObject object) {string}id
  • Return: {}
  • Requires Token: Yes

Run the API

  • node index.js run the application on port 3000 and 3001 (default)
  • NODE_ENV=production node index.js run the application on ports 5000 & 5001

To run in debug mode:

  • NODE_DEBUG=/file to debug/ node index.js
  • Example: NODE_DEBUG=handlers node index.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published