Code Monkey home page Code Monkey logo

pizza-delivery-api's Introduction

pizza-delivery-api

A RESTful API for Pizza Delivery

Problem Description

Imagine a pizza ordering services with the following functionality:

  1. Order a pizza:
    • Specify the desired pizza type (margarita, marinara, salami), the number of pizza items and their size (small, medium, large).
    • An order should contain information about the customer: name, address.
    • It should be possible to track the status of order delivery. (new, preparing, delivering, delivered)
  2. Update an order:
    • There should be a possibility to update the order details (pizzas/number of pizzas/size).
    • There should be a possibility to change the status of order delivery. Please, pay attention, that order in some delivery statuses (e.g. delivered) could not be updated;
  3. Remove an order.
  4. Retrieve an order.
  5. List orders.
    • Provide filtering by status/customer.

Installation and Usage

  • Clone this repository
  • cd pizza-delivery-api
  • npm install
  • npm test //for running test cases
  • npm start //for starting the appication

Make sure you have a postgres database setup and credentials are given in a .env file.

Docker

docker-compose up --build

POST

Endpoint /api/user/add

Body

{
	"first_name": "Rifat Bin",
	"last_name": "Reza",
	"address": "House 13, Road 8/A, Uttara, Dhaka 1230",
	"email": "[email protected]"
}

Response

{
    "status": "success",
    "message": "Successfully saved customer",
    "data": {
      "id": 1,
      "first_name": "Rifat Bin",
      "last_name": "Reza",
      "address": "House 13, Road 8/A, Uttara, Dhaka 1230",
      "email": "[email protected]"
    }
}

POST

Endpoint /api/order/add

Body

{
	"type": "margarita",
	"size": "large",
	"quantity": 600,
	"customer_id": 1
}

Response

{
    "status": "success",
    "message": "Successfully saved data",
    "data": {
        "id": 8,
        "type": "margarita",
        "size": "large",
        "quantity": 600,
        "customer_id": 1,
        "delivery_status": "new",
        "updatedAt": "2019-12-07T20:34:44.523Z",
        "createdAt": "2019-12-07T20:34:44.523Z"
    }
}

POST

Endpoint /api/order/1/update

Body

{
	"quantity": 60
}

Response

{
    "status": "success",
    "message": "Successfully updated the order",
    "data": null
}

POST

Endpoint /api/order/1/status

Body

{
	"delivery_status":"delivered"
}

Response

{
    "status": "success",
    "message": "Successfully updated delivery status",
    "data": null
}

GET

Endpoint /api/order/1

Response

{
    "status": "success",
    "message": "Found the order",
    "data": {
        "order": {
            "id": 8,
            "type": "margarita",
            "size": "large",
            "quantity": 600,
            "customer_id": 1,
            "delivery_status": "new",
            "createdAt": "2019-12-07T20:34:44.523Z",
            "updatedAt": "2019-12-07T20:34:44.523Z"
        },
        "customer": {
            "first_name": "Rifat Bin",
            "last_name": "Reza",
            "address": "House 131, Road 8, Uttara, Dhaka 1230"
        }
    }
}

GET

Endpoint /api/orders/filter?delivery_status=delivered&userId=1

Response

{
    "status": "success",
    "message": "Found orders",
    "data": [
        {
            "id": 1,
            "type": "margarita",
            "size": "small",
            "quantity": 60,
            "customer_id": 1,
            "delivery_status": "delivered",
            "createdAt": "2019-12-07T13:31:33.961Z",
            "updatedAt": "2019-12-07T20:36:39.630Z",
            "customer": {
                "first_name": "Rifat Bin",
                "last_name": "Reza",
                "address": "House 131, Road 8, Uttara, Dhaka 1230"
            }
        }
    ]
}

GET

Endpoint /api/order/1/remove

Response

{
    "status": "success",
    "message": "Successfully removed the order",
    "data": null
}

pizza-delivery-api's People

Contributors

rifatbinreza avatar

Watchers

 avatar  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.