https://github.com/utkarsh1504/fd-rest-api
https://github.com/utkarsh1504/fd-rest-api
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/utkarsh1504/fd-rest-api
- Owner: Utkarsh1504
- Created: 2024-03-29T17:53:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-29T18:56:00.000Z (over 2 years ago)
- Last Synced: 2025-02-17T12:18:04.889Z (over 1 year ago)
- Language: TypeScript
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Food Delivery Backend REST API
**NOTE:** The API is deployed at [https://fd-rest-api.onrender.com/](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](https://nodejs.org/en/download) (version 20.x or later recommended)
- [PostgreSQL](https://www.postgresql.org/download/) (version 16.x or later recommended)
- npm (included with Node.js)
### Installation
1. Clone the repository:
```bash
git clone https://github.com/Utkarsh1504/fd-rest-api
cd fd-rest-api
```
2. Install dependencies:
```bash
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:
```bash
npm run dev
```
## API Documentation
The API endpoints for calculating delivery costs are documented below:
### Calculate Delivery Cost
- **POST /api/calculate-price**
- **Body**:
```json
{
"zone": "central",
"organization_id": "5",
"total_distance": 12,
"item_type": "perishable"
}
```
- **Response**:
```json
{
"total_price": 20.5
}
```