An open API service indexing awesome lists of open source software.

https://github.com/ismail-dev-code/meal-giver-server

The MealGiver Server is the core API service for the MealGiver platform โ€” a MERN stack-based food donation and redistribution system connecting restaurants with verified charities and individuals to reduce food waste.
https://github.com/ismail-dev-code/meal-giver-server

decoded dotenv express-js firebse middleware mongodb-atlas stripe-payments

Last synced: 6 months ago
JSON representation

The MealGiver Server is the core API service for the MealGiver platform โ€” a MERN stack-based food donation and redistribution system connecting restaurants with verified charities and individuals to reduce food waste.

Awesome Lists containing this project

README

          

# ๐Ÿฝ๏ธ MealGiver Server API

The **MealGiver Server** is the core API service for the MealGiver platform โ€” a MERN stack-based food donation and redistribution system connecting restaurants with verified charities and individuals to reduce food waste.

## ๐Ÿ”— Live

> โš™๏ธ Site: `https://meal-giver-web.app`

## โš™๏ธ Technologies Used

- **Node.js**
- **Express.js**
- **MongoDB**
- **Firebase Admin SDK (Authentication & Role Management)**
- **Stripe API (Payments)**
- **Dotenv**
- **CORS**
- **Firebase Token Verification**

## ๐Ÿ” Authentication & Middleware

- **Firebase Authentication** (`verifyFBToken`)
- **Role-based Authorization** (`verifyAdmin`, `verifyRestaurant`, `verifyCharity`)

## ๐Ÿ› ๏ธ Base URL

> `https://mealgiver-server.vercel.app`

## โœ… Auth & User Endpoints

| Method | Endpoint | Access | Description |
| -------- | -------------------- | ------------- | -------------------------- |
| `GET` | `/users` | Admin | Get all users |
| `POST` | `/users` | Public | Register a new user |
| `PATCH` | `/users/role/:email` | Admin | Update a userโ€™s role |
| `DELETE` | `/users/:id` | Admin | Delete a user |
| `GET` | `/users/role/:email` | Authenticated | Get current user's role |

## ๐Ÿฝ๏ธ Donations Endpoints

| Method | Endpoint | Access | Description |
| -------- | ------------------------ | ---------- | ---------------------------------- |
| `POST` | `/donations` | Restaurant | Create a new donation |
| `GET` | `/donations/restaurant` | Restaurant | Get all donations by restaurant |
| `PATCH` | `/donations/:id` | Restaurant | Update a donation |
| `DELETE` | `/donations/:id` | Restaurant | Delete a donation |
| `GET` | `/donations/featured` | Public | Get featured donations |
| `GET` | `/donations/verified` | Public | Get all verified donations |
| `GET` | `/donations/:id` | Public | Get donation details |
| `PATCH` | `/donations/approve/:id` | Admin | Approve a donation submission |

## ๐Ÿ“ฆ Donation Request Endpoints

| Method | Endpoint | Access | Description |
| ------- | --------------------------------- | ---------- | -------------------------------------------- |
| `POST` | `/requests` | Charity | Submit request for a donation |
| `GET` | `/requests/charity` | Charity | Get all requests by the logged-in charity |
| `GET` | `/requests/restaurant` | Restaurant | Get all requests for restaurantโ€™s donations |
| `PATCH` | `/requests/:id/approve` | Restaurant | Approve a charityโ€™s request |
| `PATCH` | `/requests/:id/reject` | Restaurant | Reject a charityโ€™s request |
| `GET` | `/charity/received-donations` | Charity | Get all received/picked-up donations |
| `GET` | `/charity/latest-requests/recent` | Public | Get recent charity requests (for homepage) |

## ๐Ÿšš Pickup Confirmation Endpoints

| Method | Endpoint | Access | Description |
| ------- | ----------------------------- | ------- | ------------------------ |
| `GET` | `/charity/my-pickups` | Charity | Get all assigned pickups |
| `PATCH` | `/charity/pickup-confirm/:id` | Charity | Confirm a pickup |

## ๐Ÿ’ณ Charity Role Requests (Stripe)

| Method | Endpoint | Access | Description |
| ------- | -------------------------- | ------ | -------------------------------- |
| `POST` | `/charity-role-request` | Auth | Submit role request with payment |
| `GET` | `/admin/role-requests` | Admin | View all role requests |
| `PATCH` | `/admin/role-requests/:id` | Admin | Approve or reject role request |
| `POST` | `/create-payment-intent` | Auth | Generate Stripe payment intent |

## ๐ŸŒŸ Review Endpoints

| Method | Endpoint | Access | Description |
| ------ | ------------------------- | ------- | ----------------------------------- |
| `POST` | `/reviews` | Charity | Submit a review for a donation |
| `GET` | `/reviews?donationId=xxx` | Public | Get reviews for a specific donation |
| `GET` | `/reviews/mine` | Charity | Get logged-in user's reviews |
| `GET` | `/reviews/community` | Public | Get latest community stories |

## ๐Ÿ“Š Dashboard Stats

| Method | Endpoint | Access | Description |
| ------ | ------------------- | ---------- | --------------------------------------- |
| `GET` | `/admin/stats` | Admin | Get total stats (users, donations, etc) |
| `GET` | `/restaurant/stats` | Restaurant | Restaurant-specific stats |
| `GET` | `/charity/stats` | Charity | Charity-specific stats |

## ๐Ÿงช Testing the API

You can test the endpoints using:

- ๐Ÿงช Postman
- โš›๏ธ Frontend app integration

All secured routes require this header:
`Authorization: Bearer `

## ๐Ÿ™‹ Contributing

Feel free to fork the project, open issues, or submit PRs. Contributions, suggestions, and feedback are always welcome!

## ๐Ÿง‘โ€๐Ÿ’ป Developer

**Ismail Hossain**
๐Ÿ“ง hm.ismail772@gmail.com
๐ŸŒ Noakhali, Bangladesh
๐Ÿ”— [GitHub](https://github.com/ismail-dev-code) | [LinkedIn](https://www.linkedin.com/in/ismail-hossain24)