Skip to content

andresilveira1/pizza-shop-api

Repository files navigation

Pizza shop API

Introduction

This project is a part of the ReactJS course from Rocketseat.

This project was built with Bun, TypeScript, Drizzle and ElysiaJS.

The routes provide by this API allow a application of a store to handle with orders and check the finance result with metrics. This API doesn't have a route to create orders, there is fake data is provided to test this back-end and a manager account is created with the email:

[email protected]

Front-End

Pizza Shop WEB

Features

  • Register a store.
  • Login with magic link (the link will be sent to console.log).
  • Update store profile.
  • Orders List.
  • Orders details.
  • Change order status.
  • Total revenue by period.
  • Total revenue on the current month and a comparison with previous month.
  • Total orders on current day and a comparison with previous day.
  • Total orders on the current month and a comparison with previous month.
  • Total revenue on the current month and a comparison with previous month.
  • Total orders canceled on the current month and a comparison with previous month.
  • Most popular products.

Run

To run Docker is needed.

  git clone https://github.com/andresilveira1/pizza-shop-api.git

  bun install

  docker compose up -d

  bun migrate

  bun seed

  bun dev

HTTP

Sign in

POST/authenticate

{
  "email": "[email protected]"
}

GET/auth-links/authenticate

  The authenticate link is sent to console.log and a cookie will be available.

GET/me

{
  "id": "x5wp1fb1uud0z04gniqra4wi",
  "name": "User name",
  "email": "[email protected]",
  "phone": null,
  "role": "manager",
  "createdAt": "2024-08-08T21:13:28.749Z",
  "updatedAt": "2024-08-08T21:13:28.749Z"
}

POST/restaurants

{
  "restaurantName": "Store name",
  "managerName": "Manager name",
  "email": "[email protected]",
  "phone": "987654321"
}

PUT/update-restaurant-profile

{
  "name": "Store name",
  "description": "Store description"
}

GET/managed-restaurant

{
  "id": "ubp1v6dzg9kmjkhmcptwxd8i",
  "name": "Store name",
  "description": "Store description",
  "managerId": "x5wp1fb1uud0z04gniqra4wi",
  "createdAt": "2024-08-08T21:13:28.754Z",
  "updatedAt": "2024-08-08T21:13:28.754Z"
}

GET/orders

get orders with query, a max of 10 orders per page.

name: orderId
value: e9ecfsk65bak2tztnnmwdhdc

name: customerName
value: Name example

name: status
value: pending | processing | delivering | delivered | canceled

name: pageIndex
value: 1

GET/orders/:orderId

{
  "id": "l31t4onrliipwkkx5hpcqtns",
  "status": "processing",
  "totalInCents": 235,
  "createdAt": "2024-08-07T23:01:15.324Z",
  "customer": {
    "name": "Name example",
    "phone": null,
    "email": "[email protected]"
  },
  "ordersItems": [
    {
      "id": "pxq96pfk0mu9gb9id56ha02i",
      "priceInCents": 235,
      "quantity": 1,
      "product": {
        "name": "Example"
      }
    }
  ]
}

PATCH/orders

Update order status.

/orders/:orderId/dispatch

/orders/:orderId/delivered

/orders/:orderId/cancel

/orders/:orderId/approve

GET/metrics

/metrics/daily-revenue-in-period

/metrics/month-revenue

/metrics/day-orders-amount

/metrics/month-orders-amount

/metrics/month-canceled-orders-amount

/metrics/popular-products

MIT License

About

This app provides a REST API to pizza shop web.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published