{"id":29024638,"url":"https://github.com/sayedio/SpareABite-server","last_synced_at":"2026-04-09T02:02:49.386Z","repository":{"id":301154857,"uuid":"1008320701","full_name":"sayedio/SpareABite-server","owner":"sayedio","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-25T11:41:43.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-08T16:40:36.634Z","etag":null,"topics":["authorization","cors","express-js","firebase-auth","mongodb","nodejs","tokenization","vercel"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sayedio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-25T11:11:48.000Z","updated_at":"2025-06-25T12:04:49.000Z","dependencies_parsed_at":"2025-06-25T12:49:12.629Z","dependency_job_id":null,"html_url":"https://github.com/sayedio/SpareABite-server","commit_stats":null,"previous_names":["sayedsheikh/spareabite-server","sayedio/spareabite-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sayedio/SpareABite-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayedio%2FSpareABite-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayedio%2FSpareABite-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayedio%2FSpareABite-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayedio%2FSpareABite-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sayedio","download_url":"https://codeload.github.com/sayedio/SpareABite-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayedio%2FSpareABite-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31581864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"online","status_checked_at":"2026-04-09T02:00:06.848Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authorization","cors","express-js","firebase-auth","mongodb","nodejs","tokenization","vercel"],"created_at":"2025-06-26T04:18:31.350Z","updated_at":"2026-04-09T02:02:49.370Z","avatar_url":"https://github.com/sayedio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🍱 Spare A Bite – Backend API\n\n## 🚀 Purpose\n\nThis is the backend server for the Spare A Bite web application, a platform that helps connect food donors with people in need. It handles food listings, food requests, reviews, and authentication using Firebase and MongoDB.\n\n## 🌐 Live URL\n\n🔗 [Spare A Bite API - Live Demo](https://spare-a-bite-server.vercel.app)\n\n## ✨ Key Features\n\n- **Authentication**: Uses Firebase Admin SDK to verify Firebase-issued JWT tokens\n- **Middleware**: Includes `verifyToken` and `verifyEmail` for secure access control\n- **Food Management**: Full CRUD operations for food listings\n- **Request System**: Handle food requests between users\n- **Review System**: Submit and view reviews\n- **CORS Support**: Secure cross-origin requests\n\n## 🔒 Authentication\n\n- Uses Firebase Admin SDK to verify Firebase-issued JWT tokens.\n- `verifyToken` middleware checks for valid Bearer token.\n- `verifyEmail` middleware ensures the user can only access their own data.\n---\n\n## 📦 npm Packages Used\n\n- [`express`](https://www.npmjs.com/package/express)\n- [`mongodb`](https://www.npmjs.com/package/mongodb)\n- [`firebase-admin`](https://www.npmjs.com/package/firebase-admin)\n- [`dotenv`](https://www.npmjs.com/package/dotenv)\n- [`cors`](https://www.npmjs.com/package/cors)\n\n## 🛠️ How to Run Locally\n\nFollow these steps to run the **Spare A Bite API** on your local machine:\n\n### Step 1: Clone the Repository\n\n```bash\ngit clone https://github.com/your-username/spare-a-bite-server.git\ncd spare-a-bite-server\n```\n\n### Step 2: Install Dependencies\n\n```bash\nnpm install\n# or\nyarn install\n```\n\n### Step 3: Set Up Environment Variables\n\nCreate a `.env` file in the root directory with the following:\n\n```env\nPORT=5000\nMONGO_URI=your_mongodb_connection_string\nFIREBASE_PROJECT_ID=your_firebase_project_id\nFIREBASE_PRIVATE_KEY=your_firebase_private_key\nFIREBASE_CLIENT_EMAIL=your_firebase_client_email\n```\n\n### Step 4: Run the Server\n\n```bash\nnpm start\n# or\nyarn start\n```\n\nThe API will be available at [http://localhost:5000](http://localhost:5000)\n\n## 📄 API Endpoints\n\n### 🔹 Food Endpoints\n\n- `GET /allFoods` – All food data\n- `GET /featuredFoods` – Top 6 by quantity\n- `GET /foods?search=\u0026sort=` – Filtered/search food\n- `GET /food/:id` – Food by ID\n- `POST /food` – Add food (auth required)\n- `POST /food/:id` – Edit food (auth required)\n- `DELETE /food/:id` – Delete food (auth required)\n\n### 🔹 Requests\n\n- `POST /foodRequets` – Make a request (auth required)\n- `GET /foodRequests?email=` – See requests by user (auth + email match)\n- `DELETE /foodRequests/:id` – Cancel a request\n- `PATCH /foodRequests/:id` – Edit request note (auth + email match)\n\n### 🔹 My Foods\n\n- `GET /myManagedFoods?email=` – View foods by donor (auth + email match)\n\n### 🔹 Reviews\n\n- `GET /reviews` – All reviews\n- `POST /reviews` – Add review (auth required)\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayedio%2FSpareABite-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsayedio%2FSpareABite-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayedio%2FSpareABite-server/lists"}