{"id":25770785,"url":"https://github.com/rza-o/share-a-meal-fullstack-server","last_synced_at":"2026-04-13T19:32:01.943Z","repository":{"id":271803173,"uuid":"910131765","full_name":"Rza-O/share-a-meal-fullstack-server","owner":"Rza-O","description":"This is the backend service for the Meal Sharing application, which connects donors with food to people in need.","archived":false,"fork":false,"pushed_at":"2025-01-10T00:30:22.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-27T02:46:19.831Z","etag":null,"topics":["express","jwt","mongodb","nodejs"],"latest_commit_sha":null,"homepage":"https://share-a-meal-server.vercel.app/","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/Rza-O.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}},"created_at":"2024-12-30T15:15:30.000Z","updated_at":"2025-01-10T00:30:25.000Z","dependencies_parsed_at":"2025-01-10T01:25:39.800Z","dependency_job_id":"902827fe-096b-405b-85ad-4c8c921d2699","html_url":"https://github.com/Rza-O/share-a-meal-fullstack-server","commit_stats":null,"previous_names":["rza-o/share-a-meal-fullstack-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Rza-O/share-a-meal-fullstack-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rza-O%2Fshare-a-meal-fullstack-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rza-O%2Fshare-a-meal-fullstack-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rza-O%2Fshare-a-meal-fullstack-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rza-O%2Fshare-a-meal-fullstack-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rza-O","download_url":"https://codeload.github.com/Rza-O/share-a-meal-fullstack-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rza-O%2Fshare-a-meal-fullstack-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31768636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["express","jwt","mongodb","nodejs"],"created_at":"2025-02-27T02:37:10.896Z","updated_at":"2026-04-13T19:32:01.915Z","avatar_url":"https://github.com/Rza-O.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Meal Sharing Backend\n\nThis is the backend service for the **Meal Sharing** application, which connects donors with food to people in need, aiming to reduce food surplus and waste. The backend is built with **Node.js** and **Express**, using **MongoDB** as the database.\n\n## Live URL\nThe backend is hosted and available at:\n[Share-A-Meal-Backend](https://share-a-meal-server.vercel.app)\n\n---\n\n## Purpose\nThis backend provides a secure and scalable API to manage food donations, requests, and user authentication. It supports CRUD operations for food items, authentication with JWT, and cookies for session management. The backend integrates seamlessly with the frontend of the Meal Sharing application.\n\n---\n\n## Key Features\n\n### Authentication\n- **JWT-Based Authentication**: Securely authenticate users and issue JWT tokens.\n- **Token Management**: Tokens are stored in **http-only cookies** for enhanced security.\n\n### Food Management\n- **Add Foods**: Allows authenticated users to donate food items.\n- **Get All Foods**: Fetch all available food items with search and sort functionality.\n- **Get Single Food**: Retrieve detailed information about a specific food item.\n- **Update Foods**: Update food details like status, donor, or requester.\n- **Delete Foods**: Remove food items from the database.\n\n### User-Specific Data\n- **My Foods**: Fetch foods donated by the authenticated user.\n- **My Requests**: Fetch foods requested by the authenticated user.\n\n### Advanced APIs\n- **Featured Foods**: Retrieve a list of top food donations for the homepage.\n- **Cancel Request**: Allow users to cancel their food requests and reset the food status.\n\n### Error Handling\n- **Unauthorized Access**: Handles cases when a user tries to access restricted endpoints without a valid token.\n- **Bad Request**: Validates inputs and handles missing parameters.\n\n---\n\n## API Endpoints\n\n### Authentication\n- **POST** `/jwt`: Issues a JWT token upon successful login.\n- **POST** `/logout`: Logs the user out by clearing the token cookie.\n\n### Food Management\n- **POST** `/add-foods`: Adds a food item to the database (Authenticated).\n- **GET** `/all-foods`: Retrieves all available food items (with optional search and sort).\n- **GET** `/food/:id`: Fetches a single food item by ID.\n- **PATCH** `/food/:id`: Updates a food item by ID (Authenticated).\n- **DELETE** `/food/:id`: Deletes a food item by ID.\n\n### User-Specific APIs\n- **GET** `/my-foods`: Retrieves all foods donated by the authenticated user (Authenticated).\n- **GET** `/my-requests`: Retrieves all foods requested by the authenticated user (Authenticated).\n\n### Miscellaneous\n- **PATCH** `/cancel-request/:id`: Cancels a food request and resets the food status.\n- **GET** `/featured`: Retrieves top food donations for the homepage.\n\n---\n\n## Installation\n\n### Prerequisites\n- Node.js (v16 or higher)\n- MongoDB database (Atlas or Local)\n\n### Steps\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/your-repo/meal-sharing-backend.git\n   cd meal-sharing-backend\n   ```\n2. Install dependencies:\n   ```bash\n   npm install\n   ```\n3. Create a `.env` file and configure the following environment variables:\n   ```env\n   PORT=9000\n   DB_USER=\u003cyour-mongodb-username\u003e\n   DB_PASS=\u003cyour-mongodb-password\u003e\n   ACCESS_TOKEN_SECRET=\u003cyour-jwt-secret\u003e\n   NODE_ENV=development\n   ```\n4. Start the server:\n   ```bash\n   npm start\n   ```\n\n---\n\n## Dependencies\n\n- **[cookie-parser](https://www.npmjs.com/package/cookie-parser)**: Parse cookies for managing http-only JWTs.\n- **[cors](https://www.npmjs.com/package/cors)**: Enable cross-origin resource sharing.\n- **[dotenv](https://www.npmjs.com/package/dotenv)**: Manage environment variables securely.\n- **[express](https://www.npmjs.com/package/express)**: Web framework for Node.js.\n- **[jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken)**: Manage authentication tokens.\n- **[mongodb](https://www.npmjs.com/package/mongodb)**: Connect and interact with MongoDB.\n\n---\n\n## Development\n### Running in Development Mode\nStart the server in development mode with:\n```bash\nnpm run dev\n```\nThe server will reload automatically on code changes.\n\n---\n\n## Contact\nFor questions or feedback, please reach out at [shahreza.dev@gmail.com](mailto:shahreza.dev@gmail.com).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frza-o%2Fshare-a-meal-fullstack-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frza-o%2Fshare-a-meal-fullstack-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frza-o%2Fshare-a-meal-fullstack-server/lists"}