Utkarsh1504/fd-rest-api

★ 0Forks 0TypeScriptGitHub ↗Compare

README

Food Delivery Backend REST API

NOTE: The API is deployed at https://fd-rest-api.onrender.com/

Features Implemented:

  • Prisma ORM, PostgreSQL for database
  • Dynamic pricing module for calculating delivery costs.
  • REST API endpoints for dynamic pricing calculations.
  • Input validation using zod.
  • Used dummy data for testing using the seed.ts (for seeding)

Getting Started

Prerequisites

  • Node.js (version 20.x or later recommended)
  • PostgreSQL (version 16.x or later recommended)
  • npm (included with Node.js)

Installation

  1. Clone the repository:

    git clone https://github.com/Utkarsh1504/fd-rest-api
    cd fd-rest-api
  2. Install dependencies:

    npm install
  3. Set up the database:

    • Create a PostgreSQL database. (render or neon)
    • Create .env file
    • Add the PostgreSQL URL in the .env file as DATABASE_URL=
  4. Run the server:

    npm run dev

API Documentation

The API endpoints for calculating delivery costs are documented below:

Calculate Delivery Cost

  • POST /api/calculate-price
  • Body:
    {
      "zone": "central",
      "organization_id": "5",
      "total_distance": 12,
      "item_type": "perishable"
    }
  • Response:
    {
      "total_price": 20.5
    }

Contributors

Utkarsh1504

Issues