{"id":28533367,"url":"https://github.com/mohamedabouzid1/storeapi","last_synced_at":"2026-05-04T13:37:17.284Z","repository":{"id":296750588,"uuid":"994111572","full_name":"MohamedAbouzid1/StoreAPI","owner":"MohamedAbouzid1","description":"A RESTful API for managing product data built with Node.js, Express, and MongoDB","archived":false,"fork":false,"pushed_at":"2025-06-01T19:33:37.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-05T02:21:52.581Z","etag":null,"topics":["backend","expressjs","mongodb","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MohamedAbouzid1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-01T08:23:46.000Z","updated_at":"2025-06-01T19:33:40.000Z","dependencies_parsed_at":"2025-06-02T05:35:07.023Z","dependency_job_id":"b8463ec0-a9cc-493e-bbd1-233ff467c3a6","html_url":"https://github.com/MohamedAbouzid1/StoreAPI","commit_stats":null,"previous_names":["mohamedabouzid1/storeapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MohamedAbouzid1/StoreAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedAbouzid1%2FStoreAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedAbouzid1%2FStoreAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedAbouzid1%2FStoreAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedAbouzid1%2FStoreAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MohamedAbouzid1","download_url":"https://codeload.github.com/MohamedAbouzid1/StoreAPI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedAbouzid1%2FStoreAPI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279183262,"owners_count":26121361,"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","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"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":["backend","expressjs","mongodb","nodejs"],"created_at":"2025-06-09T17:06:48.446Z","updated_at":"2025-10-16T11:25:04.864Z","avatar_url":"https://github.com/MohamedAbouzid1.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Store API\r\n\r\nA RESTful API for managing product data built with Node.js, Express, and MongoDB. This API provides endpoints to retrieve, filter, sort, and paginate product information.\r\n\r\n## Features\r\n\r\n- **Product Management**: Retrieve product information with advanced filtering\r\n- **Search \u0026 Filter**: Search by name, company, featured status, and price/rating ranges\r\n- **Sorting**: Sort products by various fields (name, price, rating, etc.)\r\n- **Field Selection**: Choose specific fields to return in the response\r\n- **Pagination**: Navigate through large datasets with page and limit parameters\r\n- **Numeric Filters**: Apply range-based filtering for price and rating\r\n\r\n## Tech Stack\r\n\r\n- **Backend**: Node.js, Express.js\r\n- **Database**: MongoDB with Mongoose ODM\r\n- **Environment Management**: dotenv\r\n- **Error Handling**: express-async-errors\r\n- **Development**: nodemon for auto-restart\r\n\r\n## Installation\r\n\r\n1. **Clone the repository**\r\n   ```bash\r\n   git clone \u003crepository-url\u003e\r\n   cd StoreAPI\r\n   ```\r\n\r\n2. **Install dependencies**\r\n   ```bash\r\n   npm install\r\n   ```\r\n\r\n3. **Set up environment variables**\r\n   Create a `.env` file in the root directory:\r\n   ```env\r\n   MONGO_URI=your_mongodb_connection_string\r\n   PORT=5000\r\n   ```\r\n\r\n4. **Populate the database**\r\n   ```bash\r\n   node populate.js\r\n   ```\r\n\r\n5. **Start the development server**\r\n   ```bash\r\n   npm start\r\n   ```\r\n\r\nThe server will start on `http://localhost:5000`\r\n\r\n## API Endpoints\r\n\r\n### Base URL\r\n```\r\nhttp://localhost:5000/api/v1/products\r\n```\r\n\r\n### Get All Products\r\n```http\r\nGET /api/v1/products\r\n```\r\n\r\n### Get Static Products (Price \u003c $30)\r\n```http\r\nGET /api/v1/products/static\r\n```\r\n\r\n## Query Parameters\r\n\r\n### Basic Filtering\r\n- `featured`: Filter by featured status (`true` or `false`)\r\n- `company`: Filter by company name (`ikea`, `liddy`, `caressa`, `marcos`)\r\n- `name`: Search products by name (case-insensitive partial match)\r\n\r\n### Numeric Filtering\r\nUse `numericFilters` parameter with the following operators:\r\n- `\u003e`: Greater than\r\n- `\u003e=`: Greater than or equal\r\n- `=`: Equal to\r\n- `\u003c`: Less than\r\n- `\u003c=`: Less than or equal\r\n\r\n**Supported fields**: `price`, `rating`\r\n\r\nExample:\r\n```\r\n?numericFilters=price\u003e50,rating\u003e=4.5\r\n```\r\n\r\n### Sorting\r\n- `sort`: Comma-separated list of fields to sort by\r\n- Default: Sorted by `createdAt`\r\n\r\nExample:\r\n```\r\n?sort=name,price\r\n?sort=-price (descending order)\r\n```\r\n\r\n### Field Selection\r\n- `fields`: Comma-separated list of fields to include in response\r\n\r\nExample:\r\n```\r\n?fields=name,price,company\r\n```\r\n\r\n### Pagination\r\n- `page`: Page number (default: 1)\r\n- `limit`: Number of items per page (default: 10)\r\n\r\nExample:\r\n```\r\n?page=2\u0026limit=5\r\n```\r\n\r\n## Example Requests\r\n\r\n### Get featured products under $100\r\n```http\r\nGET /api/v1/products?featured=true\u0026numericFilters=price\u003c100\r\n```\r\n\r\n### Search for chairs from IKEA\r\n```http\r\nGET /api/v1/products?name=chair\u0026company=ikea\r\n```\r\n\r\n### Get products sorted by price (highest first) with only name and price fields\r\n```http\r\nGET /api/v1/products?sort=-price\u0026fields=name,price\r\n```\r\n\r\n### Get second page of products with 5 items per page\r\n```http\r\nGET /api/v1/products?page=2\u0026limit=5\r\n```\r\n\r\n### Complex filtering: Featured products from Caressa or Liddy, price between $20-$100, rating above 4\r\n```http\r\nGET /api/v1/products?featured=true\u0026numericFilters=price\u003e=20,price\u003c=100,rating\u003e4\u0026sort=-rating\r\n```\r\n\r\n## Response Format\r\n\r\n```json\r\n{\r\n  \"products\": [\r\n    {\r\n      \"_id\": \"product_id\",\r\n      \"name\": \"Product Name\",\r\n      \"price\": 99,\r\n      \"company\": \"company_name\",\r\n      \"rating\": 4.5,\r\n      \"featured\": true,\r\n      \"createdAt\": \"2023-01-01T00:00:00.000Z\"\r\n    }\r\n  ],\r\n  \"nbHits\": 1\r\n}\r\n```\r\n\r\n## Product Schema\r\n\r\n| Field | Type | Required | Default | Description |\r\n|-------|------|----------|---------|-------------|\r\n| name | String | Yes | - | Product name |\r\n| price | Number | Yes | - | Product price |\r\n| company | String | No | - | Company name (ikea, liddy, caressa, marcos) |\r\n| rating | Number | No | 4.5 | Product rating |\r\n| featured | Boolean | No | false | Featured status |\r\n| createdAt | Date | No | Date.now() | Creation timestamp |\r\n\r\n## Project Structure\r\n\r\n```\r\nstore-api/\r\n├── controllers/\r\n│   └── products.js          # Product controller logic\r\n├── db/\r\n│   └── connect.js           # Database connection\r\n├── middleware/\r\n│   ├── error-handler.js     # Global error handler\r\n│   └── not-found.js         # 404 handler\r\n├── models/\r\n│   └── product.js           # Product mongoose model\r\n├── routes/\r\n│   └── products.js          # Product routes\r\n├── app.js                   # Main application file\r\n├── populate.js              # Database seeding script\r\n├── products.json            # Sample product data\r\n├── package.json             # Dependencies and scripts\r\n└── .env                     # Environment variables\r\n```\r\n\r\n## Scripts\r\n\r\n- `npm start`: Start the development server with nodemon\r\n- `node populate.js`: Populate the database with sample data\r\n\r\n## Error Handling\r\n\r\nThe API includes comprehensive error handling:\r\n- **404 Not Found**: For non-existent routes\r\n- **500 Internal Server Error**: For server errors\r\n- All async errors are caught and handled appropriately\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Contributing\r\n\r\n1. Fork the repository\r\n2. Create a feature branch (`git checkout -b feature/new-feature`)\r\n3. Commit your changes (`git commit -am 'Add new feature'`)\r\n4. Push to the branch (`git push origin feature/new-feature`)\r\n5. Create a Pull Request\r\n\r\n---\r\n\r\n**Note**: Make sure to keep your MongoDB connection string and other sensitive information secure by using environment variables and never committing them to version control.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamedabouzid1%2Fstoreapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohamedabouzid1%2Fstoreapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamedabouzid1%2Fstoreapi/lists"}