Skip to content
MultiCloudAWS-AzurePublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Pizza App — Back-end

REST API for the Pizza App. Built with Node.js, Express, and MongoDB (Mongoose). Serves menu data (pizzas) and supports listing and adding pizzas.

Tech stack

  • Node.js + Express — HTTP server and routes
  • Mongoose — MongoDB ODM
  • CORS — Cross-origin requests enabled for front-end
  • dotenv (optional) — Environment variables from .env

Project structure

Back-end/
├── index.js           # App entry, Express setup, DB connection
├── routes/
│   └── menu.js        # Menu routes (/menu)
├── controller/
│   └── pizzaController.js
├── models/
│   └── Pizza.js       # Pizza schema
├── .env.example       # Example env vars (copy to .env)
└── package.json

Setup

Prerequisites

Install and run

  1. Clone and go to the Back-end folder

    cd Back-end
  2. Install dependencies

    npm install
  3. Environment variables

    Copy the example env file and set your MongoDB URI (and optional port):

    cp .env.example .env

    Edit .env and set:

    • MONGODB_URI — MongoDB connection string (e.g. Atlas or local)
    • PORT (optional) — Server port, default 3000

    Important: Do not commit .env or real credentials.

  4. Start the server

    • Production: npm start
    • Development (with auto-reload): npm run dev

    Server runs at http://localhost:3000 (or your PORT).

API

Base URL: http://localhost:3000 (or your deployed URL).

Menu — Pizzas

Method Endpoint Description
GET /menu/pizzas Get all pizzas
POST /menu/pizzas Create a new pizza (JSON body)

GET /menu/pizzas

  • Response: 200 — JSON array of pizza objects.

POST /menu/pizzas

  • Body (JSON):
    name (string), ingredients (string), price (number), photoName (string).
    soldOut (boolean) is optional, default false.
  • Success: 201 — Created pizza object.
  • Errors:
    • 406 — Missing required field.
    • 409 — Pizza with same name already exists.
    • 500 — Server error.

Example request:

POST /menu/pizzas
Content-Type: application/json

{
  "name": "Margherita",
  "ingredients": "Tomato, mozzarella, basil",
  "price": 12,
  "photoName": "margherita.jpg",
  "soldOut": false
}

Scripts

Command Description
npm start Run server (node index.js)
npm run dev Run with nodemon (auto-reload)
npm test Placeholder (no tests yet)

License

ISC

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages