{"id":25519564,"url":"https://github.com/ahad324/firstapi","last_synced_at":"2026-02-22T11:10:18.719Z","repository":{"id":276995377,"uuid":"930971195","full_name":"ahad324/FirstApi","owner":"ahad324","description":"🚀 A powerful RESTful API built with Node.js \u0026 Express for managing products effortlessly! 🌟 CRUD operations, filtering, sorting, and more! ","archived":false,"fork":false,"pushed_at":"2025-02-11T14:44:24.000Z","size":14,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-19T17:19:53.057Z","etag":null,"topics":["api","backend-api","expressjs","nodejs","rest-api"],"latest_commit_sha":null,"homepage":"https://firstapi-production-7502.up.railway.app/api/products","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/ahad324.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":"2025-02-11T14:12:42.000Z","updated_at":"2025-02-12T17:20:14.000Z","dependencies_parsed_at":"2025-02-11T15:47:59.654Z","dependency_job_id":null,"html_url":"https://github.com/ahad324/FirstApi","commit_stats":null,"previous_names":["ahad324/firstapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahad324%2FFirstApi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahad324%2FFirstApi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahad324%2FFirstApi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahad324%2FFirstApi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahad324","download_url":"https://codeload.github.com/ahad324/FirstApi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239699579,"owners_count":19682575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api","backend-api","expressjs","nodejs","rest-api"],"created_at":"2025-02-19T17:20:00.534Z","updated_at":"2025-12-21T07:30:14.558Z","avatar_url":"https://github.com/ahad324.png","language":"JavaScript","readme":"# Product Management API\n\n## Overview\n\nThe Product Management API is a RESTful API built with Node.js and Express, designed to manage a collection of products. It allows users to perform CRUD operations on product data, including filtering, sorting, and pagination. The API is connected to a MongoDB database using Mongoose for data modeling.\n\n## Features\n\n- **Product Management**: Create, read, update, and delete products.\n- **Filtering**: Filter products by company, name, and featured status.\n- **Sorting**: Sort products based on various fields.\n- **Pagination**: Retrieve products in a paginated format.\n- **Environment Configuration**: Use environment variables for configuration.\n\n## Technologies Used\n\n- Node.js\n- Express.js\n- MongoDB\n- Mongoose\n- dotenv\n- Nodemon (for development)\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js (v14 or higher)\n- MongoDB (local or cloud instance)\n- npm (Node package manager)\n\n### Installation\n\n1. **Clone the repository**:\n\n   ```bash\n   git clone https://github.com/ahad324/FirstApi.git\n   cd FirstApi\n   ```\n\n2. **Install dependencies**:\n\n   ```bash\n   npm install\n   ```\n\n3. **Set up environment variables**:\n\n   Create a `.env` file in the root directory and add the following:\n\n   ```plaintext\n   MONGODB_URI=\u003cyour-mongodb-uri\u003e\n   PORT=3000\n   ```\n\n   Replace `\u003cyour-mongodb-uri\u003e` with your actual MongoDB connection string.\n\n4. **Seed the database** (optional):\n\n   If you want to populate the database with initial product data, run:\n\n   ```bash\n   node productDB.js\n   ```\n\n### Running the Application\n\nTo start the server, run:\n```bash\nnpm start\n```\n\nFor development mode with automatic restarts, use:\n```bash\nnpm run dev\n```\n\nThe server will be running on `http://localhost:3000`.\n\n## API Endpoints\n\n### Get All Products\n\n- **Endpoint**: `GET /api/products`\n- **Query Parameters**:\n  - `company`: Filter by company name.\n  - `name`: Filter by product name (supports regex).\n  - `featured`: Filter by featured status (true/false).\n  - `sort`: Sort by fields (comma-separated).\n  - `select`: Select specific fields (comma-separated).\n  - `page`: Page number for pagination.\n  - `limit`: Number of products per page.\n\n**Example Requests**:\n\n1. **Retrieve products from a specific company, sorted by price and name (descending)**:\n   - **Request**:\n   ```\n   GET /api/products?company=apple\u0026sort=price,-name\u0026page=1\u0026limit=5\n   ```\n   - **Description**: This request fetches products from the company \"apple\", sorted by price in ascending order and name in descending order.\n\n2. **Retrieve featured products with a specific name, sorted by name and featured status**:\n   - **Request**:\n   ```\n   GET /api/products?company=Apple\u0026name=MacBook\u0026featured=true\u0026sort=name,featured\u0026page=1\u0026limit=10\n   ```\n   - **Description**: This request retrieves featured products with the name \"MacBook\" from the company \"Apple\", sorted by name and featured status.\n\n\n### Get All Products Testing\n\n- **Endpoint**: `GET /api/products/testing`\n- **Description**: Returns a simplified list of products with only name and company fields.\n\n**Example Request**:\n`GET /api/products/testing`\n\n## Contributing\n\nContributions are welcome! Please follow these steps:\n\n1. Fork the repository.\n2. Create a new branch (`git checkout -b feature/YourFeature`).\n3. Make your changes and commit them (`git commit -m 'Add some feature'`).\n4. Push to the branch (`git push origin feature/YourFeature`).\n5. Open a pull request.\n\n---\n\n### Made with ♥ by [AbdulAhad](https://github.com/ahad324)\n\n---\n\nThank you for exploring this project! Your feedback and contributions are always welcome.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahad324%2Ffirstapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahad324%2Ffirstapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahad324%2Ffirstapi/lists"}