GithubHelp home page GithubHelp logo

wrapperdata / crazypizzaapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marta-krzyk-dev/crazypizzaapi

0.0 1.0 0.0 158 KB

2nd homework assignment for Pirple's NodeJS master class. This project is a JSON RESTful dependency-free API for a pizza-delivery company utilizing Stripe and MailGun external services.

JavaScript 100.00%

crazypizzaapi's Introduction

Crazy Pizza API

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.

Logo

ROUTES

USERS

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.

TOKENS

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.

MENU

Method Header Query params Payload Desc
GET token* Get menu as a JSON array of pizzas.

SHOPPINGCART

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.

PURCHASE

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

Manual

Set up

  1. Download the project.
  2. Open the command prompt (for Windows, click Start icon and type in 'cmd') and go to the project directory.eg. : cd C:/HelloAPI
  3. 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)
  4. The app informs which ports are active.
  5. Open up a web browser or a tool like Postman. Start making requests. Follow the Basic scenario below to learn the most useful requests.
  6. Push Ctrl + C to stop the app.

Basic scenario:

  1. Create a user. (USERS, POST)
  2. Log in. (TOKENS, POST)
  3. View menu. (MENU, GET)
  4. Order a pizza. (SHOPPINGCART, POST)
  5. Pay for the order. (PURCHASE, POST)
  6. Check email for a receipt.
  7. Log out. (TOKENS, DELETE)

Please populate the fields in your request according to the ROUTE tables above. Required fields are marked with *.

API functionalities by route

Users

  1. Create a user (an account).
  2. Get user's data.
  3. Update user's data.
  4. Delete a user (an account).

Tokens

  1. Create a token (log into an account).
  2. Get token's data (expiration date and time).
  3. Extend token's expiration date.
  4. Delete a token (log out).

Menu

  1. Get the menu.

Shopping cart

  1. Create an order (select items from menu).
  2. List existing orders (items chosen but not yet purchased).
  3. Delete an order.

Purchase

  1. Pay for an existing order.
  2. Send an order and pay for it all in one request.

Logo: Free Vector Art by Vecteezy.com

crazypizzaapi's People

Contributors

marta-krzyk-dev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.