{"id":22739850,"url":"https://github.com/rocktohq/bike-store","last_synced_at":"2026-04-29T21:33:20.577Z","repository":{"id":264348483,"uuid":"892198843","full_name":"rocktohq/bike-store","owner":"rocktohq","description":"BikeStore Server","archived":false,"fork":false,"pushed_at":"2024-11-23T15:25:26.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T06:11:12.975Z","etag":null,"topics":["api","bike-store","bikestore","express","mongoose","nodejs","rest-api","typescript"],"latest_commit_sha":null,"homepage":"https://bike-store-server-indol.vercel.app","language":"TypeScript","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/rocktohq.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-11-21T17:16:01.000Z","updated_at":"2024-11-23T15:25:29.000Z","dependencies_parsed_at":"2024-11-23T16:29:05.256Z","dependency_job_id":"9af32563-af7c-4206-882d-c93bae638e4f","html_url":"https://github.com/rocktohq/bike-store","commit_stats":null,"previous_names":["rocktohq/bike-store"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocktohq%2Fbike-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocktohq%2Fbike-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocktohq%2Fbike-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocktohq%2Fbike-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rocktohq","download_url":"https://codeload.github.com/rocktohq/bike-store/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246273524,"owners_count":20750904,"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","bike-store","bikestore","express","mongoose","nodejs","rest-api","typescript"],"created_at":"2024-12-10T23:06:24.510Z","updated_at":"2026-04-29T21:33:20.536Z","avatar_url":"https://github.com/rocktohq.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003eBikeStore Sever\u003c/h1\u003e\n\n\u003cp\u003eBikeStore is a Node.js server app uses Express.js framework, written in typescript, integrated with MongoDB is able to manage invertory systems for bikes. This application's API has some features like add and manage products(bikes) orderring system and revenue generation.\u003c/p\u003e\n\n\u003ch2\u003eTable of Contents\u003c/h2\u003e\n\n- \u003ca href=\"#keyFeatures\"\u003e**Key Features**\u003c/a\u003e\n\n- \u003ca href=\"#technologiesUsed\"\u003e**Technologies Used**\u003c/a\u003e\n\n- \u003ca href=\"#installationGuide\"\u003e**Installation Guide**\u003c/a\u003e\n\n- \u003ca href=\"#apiEndpoints\"\u003e**API Endpoints**\u003c/a\u003e\n\n- \u003ca href=\"#errorHandling\"\u003e**Error Handling**\u003c/a\u003e\n\n\u003cdiv id=\"keyFeatures\"\u003e\n\u003ch2\u003eKey Features\u003c/h2\u003e\n\n1. **_Secure Inventory Management:_** You can add, view, update and delete bike details from your database securely validating using Zod and MongooseSchema.\n\n2. **_Order and Inventory Updates:_** When user places order, inventory and stocks will be automatically updated.\n\n3. **_Revenue Calculation:_** You can calculate the total revenue in one click.\n\n4. **_Search and Filter Functionality:_** Search bikes by name, brand, or category for easy access to specific products.\n\n\u003c/div\u003e\n\n\u003cdiv id=\"technologiesUsed\"\u003e\n\u003ch2\u003eTechnologies Used:\u003c/h2\u003e\n\n- **TypeScript:** We have used typeScript to code this entire application.\n\n- **Express.js:** Express.js is the most popular Node.js framework. So, we have used it for creating the Server.\n\n- **MongoDB:** Integreting with MongoDB Database\n\n- **Mongoose:** Integreting with MongoDB Query\n\n- **Zod:** We have used Zod for validating user input data.\n\n\u003c/div\u003e\n\n\u003cdiv id=\"installationGuide\"\u003e\n\u003ch2\u003eInstallation Guide\u003c/h2\u003e\n\n1. First, clone the repository to your local system\n\n```bash\ngit clone https://github.com/rocktohq/bike-store.git\n```\n\n2. Open the project folder in your code editor(ie: VS Code)\n\n```bash\ncd bike-store\ncode .\n```\n\n3. Install all dependencies. I'm using npm; you can use yarn or any dependency manager you like\n\n```bash\nnpm install\n```\n\n4. Setup the environment variables. For that, create a file .env\n\n```bash\ntouch .env\n```\n\n5. Fillup with your information\n\n```javascript\nPORT=3000 // Port number\nDATABASE_URI= // MongoDB URI\n```\n\n6. If all the steps above are done, start the server\n\n```bash\nnpm run dev\n```\n\n\u003c/div\u003e\n\n\u003cdiv id=\"apiEndpoints\"\u003e\n\u003ch2\u003eAPI Endpoints\u003c/h2\u003e\n\n1. **_Add a new Bike:_**  \n   Endpoints: `/api/products`  \n   Method: `POST`  \n   Request Body:\n\n```json\n{\n  \"name\": \"GSX-R\",\n  \"brand\": \"SUZUKI\",\n  \"price\": 200000,\n  \"category\": \"Sports\",\n  \"description\": \"THE MIGHTY BEAST. The Suzuki GSX-R Dual ABS line had defined sportbike performance for over 30 years, with more than a million sold worldwide.\",\n  \"quantity\": 7\n}\n```\n\nResponse:\n\n```json\n{\n  \"message\": \"Bike created successfully\",\n  \"success\": true,\n  \"data\": {\n    \"name\": \"GSX-R\",\n    \"brand\": \"SUZUKI\",\n    \"price\": 200000,\n    \"category\": \"Sports\",\n    \"description\": \"THE MIGHTY BEAST. The Suzuki GSX-R Dual ABS line had defined sportbike performance for over 30 years, with more than a million sold worldwide.\",\n    \"quantity\": 7,\n    \"inStock\": true,\n    \"createdAt\": \"2024-11-22T21:23:16.986Z\",\n    \"updatedAt\": \"2024-11-22T21:23:16.986Z\",\n    \"_id\": \"6740f79d04b0d6ab21c86de9\",\n    \"__v\": 0\n  }\n}\n```\n\n2. **_Get all Bikes:_**  \n   Endpoints: `/api/products`  \n   Method: `GET`  \n   Response:\n\n```json\n{\n  \"message\": \"Bikes retrieved successfully\",\n  \"status\": true,\n  \"data\": [\n    {\n      \"_id\": \"Casual\",\n      \"bikes\": [\n        {\n          \"_id\": \"6740ea200046f4e65c3fd45a\",\n          \"name\": \"Xen Xin\",\n          \"brand\": \"Xen\",\n          \"price\": 10000,\n          \"category\": \"Casual\",\n          \"description\": \"Casual bike\",\n          \"quantity\": 5,\n          \"inStock\": true,\n          \"createdAt\": \"2024-11-22T20:29:05.829Z\",\n          \"updatedAt\": \"2024-11-22T20:29:05.829Z\",\n          \"__v\": 0\n        }\n      ]\n    }\n  ]\n}\n```\n\n- Search for Products:  \n  Query: `/api/products?searchTerm=keyWords` keyWords can be product name, brand or category. We have used $regex operator to macth partialy and case-insensitive search.  \n  Response:\n\n```json\n{\n  \"message\": \"Bikes retrieved successfully\",\n  \"status\": true,\n  \"data\": [\n    {\n      \"_id\": \"6740ea030046f4e65c3fd452\",\n      \"name\": \"Gonda Z\",\n      \"brand\": \"Gonda\",\n      \"price\": 10000,\n      \"category\": \"Sports\",\n      \"description\": \"A lightweight road bike designed for speed and performance.\",\n      \"quantity\": 5,\n      \"inStock\": true,\n      \"createdAt\": \"2024-11-22T20:29:05.829Z\",\n      \"updatedAt\": \"2024-11-22T20:29:05.829Z\",\n      \"__v\": 0\n    },\n    {\n      \"_id\": \"6740ea090046f4e65c3fd454\",\n      \"name\": \"Gonda Y\",\n      \"brand\": \"Gonda\",\n      \"price\": 10000,\n      \"category\": \"Sports\",\n      \"description\": \"A lightweight road bike designed for speed and performance.\",\n      \"quantity\": 5,\n      \"inStock\": true,\n      \"createdAt\": \"2024-11-22T20:29:05.829Z\",\n      \"updatedAt\": \"2024-11-22T20:29:05.829Z\",\n      \"__v\": 0\n    }\n\n    // ...rest data will be here\n  ]\n}\n```\n\n3. **_Get a Single Bike:_**  \n    Endpoints: `/api/products/productId`  \n    Method: `GET`\n   Response:\n\n```json\n{\n  \"message\": \"Bike retrieved successfully\",\n  \"status\": true,\n  \"data\": {\n    \"_id\": \"6740b1ba9d1c3f2d2a486452\",\n    \"name\": \"Pakizum 500\",\n    \"brand\": \"Pakizum\",\n    \"price\": 10000,\n    \"category\": \"Road Bike\",\n    \"description\": \"A lightweight road bike designed for speed and performance.\",\n    \"quantity\": 9,\n    \"inStock\": true,\n    \"createdAt\": \"2024-11-22T16:30:15.177Z\",\n    \"updatedAt\": \"2024-11-22T17:19:02.305Z\",\n    \"__v\": 0\n  }\n}\n```\n\n4. **_Update a Bike:_**  \n   Endpoints: `/api/products/productId`  \n   Method: `PUT`\n   Request Body:\n\n```json\n{\n  //* Properties to update\n  \"name\": \"Honada X\"\n}\n```\n\nResponse:\n\n```json\n{\n  \"message\": \"Bike updated successfully\",\n  \"status\": true,\n  \"data\": {\n    \"_id\": \"6740b1ba9d1c3f2d2a486452\",\n    //* Updated name\n    \"name\": \"Honda X\",\n    \"brand\": \"Pakizum\",\n    \"price\": 10000,\n    \"category\": \"Road Bike\",\n    \"description\": \"Meet the revolutionary Honda X Dual ABS with the best power-to-weight ratio and acceleration in the 147.3 cm3 class.\",\n    \"quantity\": 10,\n    \"inStock\": true,\n    \"createdAt\": \"2024-11-22T16:30:15.177Z\",\n    \"updatedAt\": \"2024-11-22T21:24:04.946Z\",\n    \"__v\": 0\n  }\n}\n```\n\n5. **_Delete a Bike:_**  \n   Endpoints: `/api/products/productId`  \n   Method: `DELETE`  \n   Response:\n\n```json\n{\n  \"message\": \"Bike deleted successfully\",\n  \"status\": true,\n  \"data\": {\n    \"_id\": \"6740b1ba9d1c3f2d2a486452\",\n    \"name\": \"Honda X\",\n    \"brand\": \"Pakizum\",\n    \"price\": 10000,\n    \"category\": \"Road Bike\",\n    \"description\": \"A lightweight road bike designed for speed and performance.\",\n    \"quantity\": 10,\n    \"inStock\": true,\n    \"createdAt\": \"2024-11-22T16:30:15.177Z\",\n    \"updatedAt\": \"2024-11-22T21:24:08.881Z\",\n    \"__v\": 0\n  }\n}\n```\n\n6. **_Place an Order:_**  \n   Endpoints: `/api/orders`  \n   Method: `POST`\n   Request Body:\n\n```json\n{\n  \"email\": \"test@gmail.com\",\n  \"product\": \"6740b1ba9d1c3f2d2a486452\",\n  \"quantity\": 1,\n  \"totalPrice\": 150000\n}\n```\n\nResponse:\n\n```json\n{\n  \"message\": \"Order created successfully\",\n  \"status\": true,\n  \"data\": {\n    \"_id\": \"6740918f51ff7c69eeb13a0a\",\n    \"email\": \"test@gmail.com\",\n    \"product\": \"6740b1ba9d1c3f2d2a486452\",\n    \"quantity\": 1,\n    \"totalPrice\": 150000,\n    \"createdAt\": \"2024-11-22T16:39:41.050Z\",\n    \"updatedAt\": \"2024-11-22T16:39:41.050Z\"\n  }\n}\n```\n\n7. **_Revenue Calculation:_**  \n   Endpoints: `/api/orders/revenue`  \n   Method: `GET`  \n   Response:\n\n```json\n{\n  \"message\": \"Revenue calculated successfully\",\n  \"status\": true,\n  \"data\": {\n    \"totalRevenue\": 3600\n  }\n}\n```\n\n\u003c/div\u003e\n\n\u003cdiv id=\"errorHandling\"\u003e\n\u003ch2\u003eError Handling\u003c/h2\u003e\n\u003cp\u003eFor input data validation we have used Zod and some custom mongoose validations too.\u003c/p\u003e\nExample of error message:\n\n```json\n{\n  \"message\": \"Price must be positive number!\",\n  \"success\": false,\n  \"error\": {\n    \"name\": \"ZodError\",\n    \"errors\": {\n      \"code\": \"too_small\",\n      \"minimum\": 0,\n      \"type\": \"number\",\n      \"inclusive\": false,\n      \"exact\": false,\n      \"message\": \"Price must be positive number!\",\n      \"path\": [\"price\"]\n    }\n  },\n  \"stack\": \"ZodError:...\"\n}\n```\n\nAnother example:\n\n```json\n{\n  \"message\": \"Bike not found\",\n  \"success\": false,\n  \"error\": {\n    \"name\": \"Bike not found\",\n    \"errors\": {}\n  },\n  \"stack\": \"\"\n}\n```\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocktohq%2Fbike-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frocktohq%2Fbike-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocktohq%2Fbike-store/lists"}