{"id":18743843,"url":"https://github.com/devmarkson/store-api","last_synced_at":"2025-11-21T23:30:14.362Z","repository":{"id":187337322,"uuid":"675146010","full_name":"DevMarkson/STORE-API","owner":"DevMarkson","description":"The Store API is designed to facilitate the management and retrieval of product information for a store. ","archived":false,"fork":false,"pushed_at":"2023-08-10T05:50:11.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-28T19:46:33.448Z","etag":null,"topics":[],"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/DevMarkson.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":"2023-08-06T00:01:59.000Z","updated_at":"2024-08-15T00:09:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a18ee6d-c714-481f-ab59-20d7de540f9d","html_url":"https://github.com/DevMarkson/STORE-API","commit_stats":null,"previous_names":["markson17/store-api","devmarkson/store-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FSTORE-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FSTORE-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FSTORE-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FSTORE-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevMarkson","download_url":"https://codeload.github.com/DevMarkson/STORE-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239627301,"owners_count":19670844,"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":[],"created_at":"2024-11-07T16:12:42.556Z","updated_at":"2025-11-21T23:30:14.311Z","avatar_url":"https://github.com/DevMarkson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Store API Documentation\n\nWelcome to the Store API Documentation. This guide outlines the endpoints, functionalities, and setup instructions for the Node.js-based Store API, which interacts with a MongoDB database to manage and retrieve product information.\n\n## Table of Contents\n- [Introduction](#introduction)\n- [Database Schema](#database-schema)\n- [JSON Data Population](#json-data-population)\n- [Endpoints and Examples](#endpoints-and-examples)\n  - [Get All Products](#get-all-products)\n  - [Get All Products (Static)](#get-all-products-static)\n\n## Introduction\n\nThe Store API is designed to facilitate the management and retrieval of product information for a store. This API allows you to access various product details, including names, prices, ratings, and company associations. It offers two primary endpoints: one for dynamic queries and another for fetching a static list of products. The API is built using Node.js, MongoDB for data storage, and Express for routing.\n\n## Database Schema\n\nThe MongoDB database schema is structured as follows:\n\n```javascript\nconst mongoose = require('mongoose');\n\nconst ProductSchema = new mongoose.Schema({\n  name: {\n    type: String,\n    required: [true, 'Product name must be provided']\n  },\n  price: {\n    type: Number,\n    required: [true, 'Product price must be provided']\n  },\n  featured: {\n    type: Boolean,\n    default: false\n  },\n  rating: {\n    type: Number,\n    default: 4.5\n  },\n  createdAt: {\n    type: Date,\n    default: Date.now()\n  },\n  company: {\n    type: String,\n    enum: {\n      values: ['ikea', 'liddy', 'caressa', 'marcos'],\n      message: '{VALUE} is not supported'\n    }\n  }\n});\n\nmodule.exports = mongoose.model('Product', ProductSchema);\n```\n\n## JSON Data Population\n\nThe provided JSON file (`products.json`) is used to populate the database with initial product data. The script in `populate.js` connects to the database and inserts the products.\n\n## Endpoints\n\n### Get All Products\n\nThis endpoint allows for dynamic querying of products based on various parameters.\n\n**URL:** `/api/v1/products`\n**Method:** `GET`\n\n**Query Parameters:**\n\n- `featured`: Filter by featured products.\n- `company`: Filter by company.\n- `name`: Search for products by name.\n- `sort`: Sort the products (comma-separated field names).\n- `fields`: Select specific fields to include in the response.\n- `numericFilters`: Apply numeric filtering conditions (e.g., '\u003e100').\n\n#### Response\n\nThe response will contain the following fields:\n\n- `products`: An array of product objects based on the query.\n- `nbHits`: The count of products in the response.\n\n**Pagination:**\n\n- The `page` parameter controls the page number of the results (default: 1).\n- The `limit` parameter controls the number of products per page (default: 10).\n\n#### Examples\n\n**Request:**\n```http\nGET localhost:3000/api/v1/products?featured=true\u0026company=ikea\u0026sort=price\u0026fields=name,price\n```\n\n```json\n{\n  \"products\": [\n    {\n      \"name\": \"albany sectional\",\n      \"price\": 109,\n      \"rating\": 5\n    },\n    {\n      \"name\": \"albany table\",\n      \"price\": 309,\n      \"rating\": 4.9\n    },\n    {\n      \"name\": \"bar stool\",\n      \"price\": 40,\n      \"rating\": 4.6\n    },\n    {\n      \"name\": \"modern poster\",\n      \"price\": 30\n    },\n    {\n      \"name\": \"simple chair\",\n      \"price\": 109\n    },\n    {\n      \"name\": \"utopia sofa\",\n      \"price\": 79\n    }\n  ],\n  \"nbHits\": 6\n}\n```\n\n### Get All Products (Static)\n\nThis endpoint returns a static list of products from the database.\n\n**URL:** `/api/products/static`\n**Method:** `GET`\n\n#### Response\n\nThe response will contain the following fields:\n\n- `products`: An array of product objects containing 'name' and 'price' fields.\n- `nbHits`: The count of products in the response.\n\n#### Examples\n\n**Request:**\n\n```http\nGET localhost:3000/api/products/static\n```\n\n**Response:**\n```json\n{\n  \"products\": [\n    {\n      \"name\": \"accent chair\",\n      \"price\": 25,\n      \"company\": \"marcos\",\n      \"rating\": 4\n    },\n    {\n      \"name\": \"albany sectional\",\n      \"price\": 109,\n      \"company\": \"liddy\",\n      \"rating\": 5\n    },\n    {\n      \"name\": \"albany table\",\n      \"price\": 309,\n      \"company\": \"liddy\",\n      \"rating\": 4.9\n    },\n    {\n      \"name\": \"armchair\",\n      \"price\": 125,\n      \"company\": \"marcos\",\n      \"rating\": 4.8\n    },\n    {\n      \"name\": \"bar stool\",\n      \"price\": 40,\n      \"company\": \"liddy\",\n      \"rating\": 4.6\n    },\n    {\n      \"name\": \"dining table\",\n      \"price\": 42,\n      \"company\": \"ikea\",\n      \"rating\": 4.55\n    },\n    // ... more products\n  ],\n  \"nbHits\": 20\n}\n```\nThank you for taking the time to dive into the Store API Documentation! I truly hope this guide has been helpful in providing insights into the endpoints, functionalities, and setup process for my Node.js-based Store API. If you ever have questions, feedback, or new ideas that stem from your own implementation, please don't hesitate to get in touch. As you continue crafting your unique applications using the API, remember that your creativity knows no bounds.\n\nThank you, we can connect on Twitter, click my name \n[Favour Markson](https://twitter.com/MarksonFavour1)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevmarkson%2Fstore-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevmarkson%2Fstore-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevmarkson%2Fstore-api/lists"}