├── .nvmrc
├── .gitignore
├── vercel.json
├── .github
├── dependabot.yml
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── data
├── tag.json
├── brand.json
├── category.json
├── test.json
└── products.json
├── package.json
├── commonFunctions
└── sorting_asc_des.js
├── LICENSE
├── CONTRIBUTING.md
├── CODE_OF_CONDUCT.md
├── index.js
└── Readme.md
/.nvmrc:
--------------------------------------------------------------------------------
1 | v20.10.0
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 |
3 | package-lock.json
4 | yarn.lock
5 |
6 | .vercel
7 | .vscode
8 | vercel.json
9 |
--------------------------------------------------------------------------------
/vercel.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "builds": [
4 | {
5 | "src": "/index.js",
6 | "use": "@vercel/node"
7 | }
8 | ],
9 | "routes": [
10 | {
11 | "src": "/(.*)",
12 | "dest": "/"
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # Basic `dependabot.yml` file with
2 | # minimum configuration for two package managers
3 |
4 | version: 2
5 | updates:
6 | # Enable version updates for npm
7 | - package-ecosystem: "npm"
8 | # Look for `package.json` and `lock` files in the `root` directory
9 | directory: "/"
10 | # Check the npm registry for updates every week
11 | schedule:
12 | interval: "weekly"
13 |
--------------------------------------------------------------------------------
/data/tag.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "tagID": "1",
4 | "tag": "Architecture"
5 | },
6 | {
7 | "tagID": "2",
8 | "tag": "Interior"
9 | },
10 | {
11 | "tagID": "3",
12 | "tag": "Dining"
13 | },
14 | {
15 | "tagID": "4",
16 | "tag": "Trendy"
17 | },
18 | {
19 | "tagID": "5",
20 | "tag": "Decor"
21 | },
22 | {
23 | "tagID": "6",
24 | "tag": "Lawn"
25 | }
26 | ]
27 |
--------------------------------------------------------------------------------
/data/brand.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "brandID": "1",
4 | "brand": "PHILIPS"
5 | },
6 | {
7 | "brandID": "2",
8 | "brand": "CASIO"
9 | },
10 | {
11 | "brandID": "3",
12 | "brand": "RFL"
13 | },
14 | {
15 | "brandID": "4",
16 | "brand": "BASEUS"
17 | },
18 | {
19 | "brandID": "5",
20 | "brand": "PARTEX"
21 | },
22 | {
23 | "brandID": "6",
24 | "brand": "FLOOM"
25 | }
26 | ]
27 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mrittik-server",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "node index.js",
8 | "dev": "nodemon index.js",
9 | "test": "echo \"Error: no test specified\" && exit 1"
10 | },
11 | "keywords": [],
12 | "author": "",
13 | "license": "ISC",
14 | "dependencies": {
15 | "cors": "latest",
16 | "express": "latest",
17 | "nodemon": "latest",
18 | "vercel": "^34.2.3"
19 | },
20 | "resolutions": {
21 | "inflight": "1.0.6"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/commonFunctions/sorting_asc_des.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This function take two parameters, first is- order (pathname) which either includes 'aes' or 'des' and another is products array which will be sorting ascending to descending or descending to ascending order
3 | * And finally this function return sorting values as an array
4 | */
5 |
6 | const sorting_asc_des =(order, products_to_sort)=> {
7 | let sorted_products = []
8 | sorted_products = products_to_sort.sort((a, b)=> {
9 | if(order.includes('aes')){
10 | return parseInt(a.price) - parseInt(b.price);
11 | } else if (order.includes('des')){
12 | return parseInt(b.price) - parseInt(a.price);
13 | }
14 | })
15 |
16 | return sorted_products
17 | }
18 |
19 | module.exports = sorting_asc_des
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. Windows]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Additional context**
32 | Add any other context about the problem here.
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [2025] [Md. Hasanul Banna Khan Abir]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | Thank you for your interest in contributing to Mrittik-Server! Whether it's reporting a bug, submitting a feature request, or contributing code, we appreciate all contributions. To get started, please follow the guidelines below.
4 |
5 | ## Reporting Bugs
6 |
7 | If you have found a bug in Mrittik-Server, please open an issue in the [issue tracker](https://github.com/hbkabir004/Mrittik-Server/issues) and provide the following information:
8 |
9 | - A clear and concise description of the bug.
10 | - Steps to reproduce the bug.
11 | - Expected behavior and actual behavior.
12 | - Any error messages or logs that are relevant.
13 |
14 | ## Feature Requests
15 |
16 | If you have a feature request for Mrittik-Server, please open an issue in the [issue tracker](https://github.com/hbkabir004/Mrittik-Server/issues) and provide the following information:
17 |
18 | - A clear and concise description of the feature.
19 | - Any relevant use cases or examples.
20 | - Any additional information that may be helpful.
21 |
22 | ## Contributing Code
23 |
24 | We welcome contributions of code from the community. To contribute code, please follow these steps:
25 |
26 | 1. Fork the repository and create a new branch for your feature or bug fix.
27 | 2. Make your changes and test them thoroughly.
28 | 3. Submit a pull request to the main repository with a clear description of your changes.
29 |
30 | When contributing code, please follow these guidelines:
31 |
32 | - Write clear and concise code that follows the existing code style.
33 | - Write unit tests to ensure that your code works as expected.
34 | - Document your code using clear and concise comments.
35 |
36 | ## Code of Conduct
37 |
38 | To ensure that Mrittik-Server is a welcoming and inclusive community, we have adopted a [Code of Conduct](https://github.com/hbkabir004/Mrittik-Server/blob/main/CODE_OF_CONDUCT.md). Please read and follow this code of conduct when participating in the community.
39 |
40 | Thank you for your contributions to Mrittik-Server!
41 |
--------------------------------------------------------------------------------
/data/category.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "categoryID": "1",
4 | "name": "Bed Room",
5 | "logo": "https://i.ibb.co/VSjXpF2/8.jpg",
6 | "total": "3",
7 | "subCategoryID": "1",
8 | "item1" : "Alarm Clock",
9 | "id" : "tool_one",
10 | "href" : "#tool_one"
11 |
12 | },
13 | {
14 | "categoryID": "2",
15 | "name": "Living Room",
16 | "logo": "https://i.ibb.co/DbfhmJ2/7.jpg",
17 | "total": "3",
18 | "subCategoryID": "2",
19 | "item1" : "Center Table",
20 | "id" : "tool_two",
21 | "href" : "#tool_two"
22 |
23 | },
24 | {
25 | "categoryID": "3",
26 | "name": "Dining Room",
27 | "logo": "https://i.ibb.co/nsjsGpL/1.jpg",
28 | "total": "2",
29 | "subCategoryID": "3",
30 | "item1" : "Teal Rug",
31 | "id" : "tool_three",
32 | "href" : "#tool_three"
33 |
34 | },
35 | {
36 | "categoryID": "4",
37 | "name": "Garden",
38 | "logo": "https://i.ibb.co/6PBvbrj/3.jpg",
39 | "total": "3",
40 | "subCategoryID": "1",
41 | "item1" : "Decor Plant",
42 | "item2" : "Snake Plant",
43 | "item3" : "Plant With Stand",
44 | "id" : "tool_four",
45 | "href" : "#tool_four"
46 |
47 | },
48 | {
49 | "categoryID": "5",
50 | "name": "Wall Paintings",
51 | "logo": "https://i.ibb.co/vxRNm4J/3.jpg",
52 | "total": "3",
53 | "subCategoryID": "1",
54 | "item1" : "Black Vase",
55 | "id" : "tool_five",
56 | "href" : "#tool_five"
57 |
58 | },
59 | {
60 | "categoryID": "6",
61 | "name": "Furniture",
62 | "logo": "https://i.ibb.co/M6Smhfg/2.jpg",
63 | "total": "3",
64 | "subCategoryID": "1",
65 | "item1" : "Green Armchair",
66 | "item2" : "Wooden Center Table",
67 | "item3" : "White Armchair",
68 | "id" : "tool_six",
69 | "href" : "#tool_six"
70 |
71 | },
72 | {
73 | "categoryID": "7",
74 | "name": "Home Decor",
75 | "logo": "https://i.ibb.co/nb90WmS/6.jpg",
76 | "total": "3",
77 | "subCategoryID": "1",
78 | "item1" : "Hanging Light",
79 | "item2" : "Brown Table Lamp",
80 | "id" : "tool_seven",
81 | "href" : "#tool_seven"
82 |
83 | }
84 |
85 | ]
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/data/test.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "image":
4 | "https://cdn.builder.io/api/v1/image/assets/TEMP/2701dd50cb3d0fc0d1c60287a0e4fe1ddc4118358f34d897fbe393e4d2033b6a?placeholderIfAbsent=true&apiKey=8da3fd6b121a4ce09e18e7d9dae826f0",
5 | "discount": "45%",
6 | "icon": "https://cdn.builder.io/api/v1/image/assets/TEMP/5b28932ea12c802c58b84c8d7a63e96c47348d34871636b6ff2c5bdf510f8b8e?placeholderIfAbsent=true&apiKey=8da3fd6b121a4ce09e18e7d9dae826f0",
7 | "name": "Thomas' Everything Bagels – 20oz_6ct",
8 | "rating": 3,
9 | "originalPrice": 4.50,
10 | "discountedPrice": 2.50
11 | },
12 | {
13 | "image":
14 | "https://cdn.builder.io/api/v1/image/assets/TEMP/2701dd50cb3d0fc0d1c60287a0e4fe1ddc4118358f34d897fbe393e4d2033b6a?placeholderIfAbsent=true&apiKey=8da3fd6b121a4ce09e18e7d9dae826f0",
15 | "discount": "45%",
16 | "icon": "https://cdn.builder.io/api/v1/image/assets/TEMP/5b28932ea12c802c58b84c8d7a63e96c47348d34871636b6ff2c5bdf510f8b8e?placeholderIfAbsent=true&apiKey=8da3fd6b121a4ce09e18e7d9dae826f0",
17 | "name": "Thomas' Everything Bagels – 20oz_6ct",
18 | "rating": 3,
19 | "originalPrice": 4.50,
20 | "discountedPrice": 2.50
21 | },
22 | {
23 | "image":
24 | "https://cdn.builder.io/api/v1/image/assets/TEMP/2701dd50cb3d0fc0d1c60287a0e4fe1ddc4118358f34d897fbe393e4d2033b6a?placeholderIfAbsent=true&apiKey=8da3fd6b121a4ce09e18e7d9dae826f0",
25 | "discount": "45%",
26 | "icon": "https://cdn.builder.io/api/v1/image/assets/TEMP/5b28932ea12c802c58b84c8d7a63e96c47348d34871636b6ff2c5bdf510f8b8e?placeholderIfAbsent=true&apiKey=8da3fd6b121a4ce09e18e7d9dae826f0",
27 | "name": "Thomas' Everything Bagels – 20oz_6ct",
28 | "rating": 3,
29 | "originalPrice": 4.50,
30 | "discountedPrice": 2.50
31 | },
32 | {
33 | "image":
34 | "https://cdn.builder.io/api/v1/image/assets/TEMP/2701dd50cb3d0fc0d1c60287a0e4fe1ddc4118358f34d897fbe393e4d2033b6a?placeholderIfAbsent=true&apiKey=8da3fd6b121a4ce09e18e7d9dae826f0",
35 | "discount": "45%",
36 | "icon": "https://cdn.builder.io/api/v1/image/assets/TEMP/5b28932ea12c802c58b84c8d7a63e96c47348d34871636b6ff2c5bdf510f8b8e?placeholderIfAbsent=true&apiKey=8da3fd6b121a4ce09e18e7d9dae826f0",
37 | "name": "Thomas' Everything Bagels – 20oz_6ct",
38 | "rating": 3,
39 | "originalPrice": 4.50,
40 | "discountedPrice": 2.50
41 | },
42 | {
43 | "image":
44 | "https://cdn.builder.io/api/v1/image/assets/TEMP/2701dd50cb3d0fc0d1c60287a0e4fe1ddc4118358f34d897fbe393e4d2033b6a?placeholderIfAbsent=true&apiKey=8da3fd6b121a4ce09e18e7d9dae826f0",
45 | "discount": "45%",
46 | "icon": "https://cdn.builder.io/api/v1/image/assets/TEMP/5b28932ea12c802c58b84c8d7a63e96c47348d34871636b6ff2c5bdf510f8b8e?placeholderIfAbsent=true&apiKey=8da3fd6b121a4ce09e18e7d9dae826f0",
47 | "name": "Thomas' Everything Bagels – 20oz_6ct",
48 | "rating": 3,
49 | "originalPrice": 4.50,
50 | "discountedPrice": 2.50
51 | }
52 |
53 | ]
--------------------------------------------------------------------------------
/data/products.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "1",
4 | "name": "Decor Plant",
5 | "price": "15.00",
6 | "badge": "new",
7 | "newClass": "badge-new",
8 | "oldClass": "d-none",
9 | "img": "https://i.ibb.co/3ztPtN7/1-1.png",
10 | "categoryID": "4",
11 | "categoryName": "Garden",
12 | "tag": "Decor",
13 | "tagID": "5",
14 | "brandID": "6",
15 | "brand": "FLOOM"
16 | },
17 | {
18 | "id": "2",
19 | "name": "Hanging Light",
20 | "price": "35.00",
21 | "oldClass": "d-none",
22 | "img": "https://i.ibb.co/8BgPvQd/2-1.png",
23 | "categoryID": "7",
24 | "categoryName": "Home Decor",
25 | "tag": "Decor",
26 | "tagID": "5",
27 | "brandID": "1",
28 | "brand": "PHILIPS"
29 | },
30 | {
31 | "id": "3",
32 | "name": "Green Armchair",
33 | "price": "1500.00",
34 | "oldPrice": "13.00",
35 | "oldClass": "old_price",
36 | "badge": "sale",
37 | "newClass": "badge-sale",
38 | "img": "https://i.ibb.co/NLzL4yP/3-1.png",
39 | "categoryID": "6",
40 | "categoryName": "Furniture",
41 | "tag": "Interior",
42 | "tagID": "2",
43 | "brandID": "5",
44 | "brand": "PARTEX"
45 | },
46 | {
47 | "id": "4",
48 | "name": "Brown Table Lamp",
49 | "price": "90.00",
50 | "oldPrice": "23.00",
51 | "oldClass": "old_price",
52 | "badge": "sale",
53 | "newClass": "badge-sale",
54 | "img": "https://i.ibb.co/j8DSN4d/4-1.png",
55 | "categoryID": "7",
56 | "categoryName": "Home Decor",
57 | "tag": "Interior",
58 | "tagID": "2",
59 | "brandID": "4",
60 | "brand": "BASEUS"
61 | },
62 | {
63 | "id": "5",
64 | "name": "Wooden Center Table",
65 | "price": "2199.00",
66 | "badge": "new",
67 | "newClass": "badge-new",
68 | "oldClass": "d-none",
69 | "img": "https://i.ibb.co/Bfp6dHZ/5-1.png",
70 | "categoryID": "6",
71 | "categoryName": "Furniture",
72 | "tag": "Dining",
73 | "tagID": "3",
74 | "brandID": "5",
75 | "brand": "PARTEX"
76 | },
77 | {
78 | "id": "6",
79 | "name": "Snake Plant",
80 | "price": "19.00",
81 | "oldPrice": "23.00",
82 | "oldClass": "old_price",
83 | "img": "https://i.ibb.co/Rys1Z5n/6-1.png",
84 | "categoryID": "4",
85 | "categoryName": "Garden",
86 | "tag": "Trendy",
87 | "tagID": "4",
88 | "brandID": "6",
89 | "brand": "FLOOM"
90 | },
91 | {
92 | "id": "7",
93 | "name": "Center Table",
94 | "oldClass": "d-none",
95 | "price": "1999.00",
96 | "img": "https://i.ibb.co/VmLD95L/7-1.png",
97 | "categoryID": "2",
98 | "categoryName": "Living Room",
99 | "tag": "Dining",
100 | "tagID": "3",
101 | "brandID": "5",
102 | "brand": "PARTEX"
103 | },
104 | {
105 | "id": "8",
106 | "name": "Alarm Clock",
107 | "oldClass": "d-none",
108 | "price": "25.00",
109 | "img": "https://i.ibb.co/RcrtfrP/8-1.png",
110 | "categoryID": "1",
111 | "categoryName": "Bed Room",
112 | "tag": "Trendy",
113 | "tagID": "4",
114 | "brandID": "2",
115 | "brand": "CASIO"
116 | },
117 | {
118 | "id": "9",
119 | "name": "Black Vase",
120 | "price": "30.00",
121 | "badge": "sale",
122 | "newClass": "badge-sale",
123 | "oldClass": "d-none",
124 | "img": "https://i.ibb.co/VjdSV1g/9-1.png",
125 | "categoryID": "5",
126 | "categoryName": "Wall Paintings",
127 | "tag": "Architecture",
128 | "tagID": "1",
129 | "brandID": "3",
130 | "brand": "RFL"
131 | },
132 | {
133 | "id": "10",
134 | "name": "White Armchair",
135 | "price": "150.00",
136 | "badge": "new",
137 | "newClass": "badge-new",
138 | "oldClass": "d-none",
139 | "img": "https://i.ibb.co/XYV53Vs/10-1.png",
140 | "categoryID": "6",
141 | "categoryName": "Furniture",
142 | "tag": "Interior",
143 | "tagID": "2",
144 | "brandID": "3",
145 | "brand": "RFL"
146 | },
147 | {
148 | "id": "11",
149 | "name": "Teal Rug",
150 | "price": "190.00",
151 | "badge": "new",
152 | "newClass": "badge-new",
153 | "oldClass": "d-none",
154 | "img": "https://i.ibb.co/T1f2RfP/11-1.png",
155 | "categoryID": "3",
156 | "categoryName": "Dining Room",
157 | "tag": "Decor",
158 | "tagID": "5",
159 | "brandID": "3",
160 | "brand": "RFL"
161 | },
162 | {
163 | "id": "12",
164 | "name": "Plant With Stand",
165 | "price": "29.00",
166 | "badge": "sale",
167 | "newClass": "badge-sale",
168 | "oldClass": "d-none",
169 | "img": "https://i.ibb.co/DCQG04q/12-1.png",
170 | "categoryID": "4",
171 | "categoryName": "Garden",
172 | "tag": "Lawn",
173 | "tagID": "6",
174 | "brandID": "3",
175 | "brand": "RFL"
176 | }
177 | ]
178 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | Open Source.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express')
2 | const app = express()
3 | const port = process.env.PORT || 4000
4 | const cors = require('cors')
5 |
6 | const category = require('./data/category.json');
7 | const products = require('./data/products.json');
8 | const tags = require('./data/tag.json');
9 | const brands = require('./data/brand.json');
10 |
11 |
12 | // import function for Sorting ascending and descending order through price
13 | const sorting_asc_des = require('./commonFunctions/sorting_asc_des')
14 |
15 | // Global Middleware
16 | app.use(cors())
17 |
18 |
19 | app.get('/', (req, res) => {
20 | res.send('Server is running')
21 | })
22 |
23 | // Search Product By Category Properties
24 | app.get('/category', (req, res) => {
25 | const filters = req.query;
26 | const searched_category = category.filter(c => {
27 | let isValid = true;
28 | for (let key in filters) {
29 | isValid = isValid && c[key] == filters[key];
30 | }
31 | return isValid;
32 | });
33 | res.send(searched_category);
34 | })
35 |
36 |
37 | // Search Product By Product Properties
38 | app.get('/products', (req, res) => {
39 | const filters = req.query;
40 | const searched_product = products.filter(p => {
41 | let isValid = true;
42 | for (let key in filters) {
43 | let productSearching = p[key].toString().toLowerCase();
44 | let productFiltering = filters[key].toString().toLowerCase();
45 | isValid = isValid && productSearching.includes(productFiltering);
46 | }
47 | return isValid;
48 | });
49 | res.send(searched_product);
50 | })
51 |
52 | // Search Product By Tags
53 | app.get('/tags', (req, res) => {
54 | const filters = req.query;
55 | const searched_tag = tags.filter(p => {
56 | let isValid = true;
57 | for (let key in filters) {
58 | let tagSearching = p[key].toString().toLowerCase();
59 | let tagFiltering = filters[key].toString().toLowerCase();
60 | isValid = isValid && tagSearching.includes(tagFiltering);
61 | }
62 | return isValid;
63 | });
64 | res.send(searched_tag);
65 | })
66 |
67 | // Search Product By Brands
68 | app.get('/brands', (req, res) => {
69 | const filters = req.query;
70 | const searched_brand = brands.filter(p => {
71 | let isValid = true;
72 | for (let key in filters) {
73 | let brandSearching = p[key].toString().toLowerCase();
74 | let brandFiltering = filters[key].toString().toLowerCase();
75 | isValid = isValid && brandSearching.includes(brandFiltering);
76 | }
77 | return isValid;
78 | });
79 | res.send(searched_brand);
80 | })
81 |
82 | // Sorting Price Low to High
83 | app.get('/products/aes', (req, res) => {
84 | // Call the function and sending path and product to sorting_asc_des function for sorting
85 | const asc_products = sorting_asc_des(req.path, products) //call and pass arguments to sorting_asc_des
86 | res.send(asc_products);
87 | })
88 |
89 | // Sorting Price High to Low
90 | app.get('/products/des', (req, res) => {
91 | const des_products = sorting_asc_des(req.path, products) //call and pass arguments to sorting_asc_des
92 | res.send(des_products);
93 | })
94 |
95 |
96 | // Search Category by ID
97 | app.get('/category/:id', (req, res) => {
98 | const id = req.params.id;
99 | const selected_category = category.find(c => c.id == id);
100 | res.send(selected_category);
101 | });
102 |
103 | // Search Product by ProductID
104 | app.get('/products/:id', (req, res) => {
105 | const id = req.params.id;
106 | const selected_product = products.find(p => p.id == id);
107 | res.send(selected_product);
108 | });
109 |
110 | // Search Product by CategoryID
111 | app.get('/products/category/:id', (req, res) => {
112 | const id = req.params.id;
113 | const category_product = products.filter(product => product.categoryID === id);
114 |
115 |
116 | const filters = req.query;
117 | const category_searched_product = category_product.filter(p => {
118 | let isValid = true;
119 | for (let key in filters) {
120 | let productSearching = p[key].toString().toLowerCase();
121 | let productFiltering = filters[key].toString().toLowerCase();
122 | isValid = isValid && productSearching.includes(productFiltering);
123 | }
124 | return isValid;
125 | });
126 |
127 | res.send(category_searched_product);
128 |
129 | })
130 |
131 | // Search Product by TAG
132 | app.get('/products/tag/:id', (req, res) => {
133 | const id = req.params.id;
134 | const tag_product = products.filter(product => product.tagID === id);
135 | res.send(tag_product);
136 |
137 | })
138 |
139 | // Sorting category Products in ascending order
140 | app.get('/products/category/:id/aes', (req, res) => {
141 | const id = req.params.id;
142 | const category_product = products.filter(product => product.categoryID === id);
143 |
144 | const asc_category = sorting_asc_des(req.path, category_product) //call and pass arguments to sorting_asc_des
145 | res.send(asc_category);
146 |
147 | })
148 |
149 | // Sorting category Products in descending order
150 | app.get('/products/category/:id/des', (req, res) => {
151 | const id = req.params.id;
152 | const category_product = products.filter(product => product.categoryID === id);
153 |
154 | const des_category = sorting_asc_des(req.path, category_product) //call and pass arguments to sorting_asc_des
155 | res.send(des_category);
156 |
157 | })
158 |
159 | app.listen(port, () => {
160 | console.log(`Server running on http://localhost:${port}`);
161 | }).on('error', (err) => {
162 | if (err.code === 'EACCES') {
163 | console.error(`Port ${port} requires elevated privileges`);
164 | process.exit(1);
165 | } else if (err.code === 'EADDRINUSE') {
166 | console.error(`Port ${port} is already in use`);
167 | process.exit(1);
168 | } else {
169 | console.error(`Error: ${err}`);
170 | process.exit(1);
171 | }
172 | });
173 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 |
2 | # 🚀 Mrittik-Server API Documentation
3 |
4 | Welcome to **Mrittik-Server** – an open-source REST API developed with **Node.js** and **Express.js**!
5 | This project is designed to help developers easily integrate **searching**, **sorting**, and **filtering** functionality into their applications.
6 |
7 | Use these APIs for building e-commerce or any project that requires advanced query capabilities.
8 |
9 | ---
10 |
11 | ## 🌐 Live API Endpoints
12 |
13 | | 🛠**Feature** | 🔗**Endpoint** | 📌**Example** |
14 | | ---------------------------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
15 | | **Get Categories** | `/category` | [View Categories](https://mrittik-server.vercel.app/category) |
16 | | **Get Products by Category** | `/products/category/${id}` | [Example](https://mrittik-server.vercel.app/products/category/1) |
17 | | **Search Categories** | `/category?[dataProperty]=[dataValue]` | [By Name](https://mrittik-server.vercel.app/category?name=Furniture)`
`[By ID](https://mrittik-server.vercel.app/category?categoryID=3) |
18 | | **Get All Products** | `/products` | [View All Products](https://mrittik-server.vercel.app/products) |
19 | | **Get Product by ID** | `/products/${id}` | [Example](https://mrittik-server.vercel.app/products/1) |
20 | | **Search Products** | `/products?[dataProperty]=[dataValue]` | [By Name](https://mrittik-server.vercel.app/products?name=Decor+Plant)`
`[By ID](https://mrittik-server.vercel.app/products?id=7) |
21 | | **Get All Tags** | `/tags` | [View Tags](https://mrittik-server.vercel.app/tags) |
22 | | **Search by Tag** | `/products?[TagName]=[SearchItem]` | [Example](https://mrittik-server.vercel.app/products?tag=a) |
23 | | **Get All Brands** | `/brands` | [View Brands](https://mrittik-server.vercel.app/brands) |
24 | | **Search by Brand** | `/products?[BrandName]=[SearchItem]` | [Example](https://mrittik-server.vercel.app/products?brand=a) |
25 |
26 | ---
27 |
28 | ## 🛠 Local Development Endpoints
29 |
30 | | 💻**Feature** | 🏠**Endpoint** | 📌**Example** |
31 | | ---------------------------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
32 | | **Get Categories** | `/category` | [Local Categories](http://localhost:4000/category) |
33 | | **Get Products by Category** | `/products/category/${id}` | [Example](http://localhost:4000/products/category/1) |
34 | | **Search Categories** | `/category?[dataProperty]=[dataValue]` | [By Name](http://localhost:4000/category?name=Furniture)`
`[By ID](http://localhost:4000/category?categoryID=3) |
35 | | **Get All Products** | `/products` | [Local Products](http://localhost:4000/products) |
36 | | **Get Product by ID** | `/products/${id}` | [Example](http://localhost:4000/products/1) |
37 | | **Search Products** | `/products?[dataProperty]=[dataValue]` | [By Name](http://localhost:4000/products?name=Decor+Plant)`
`[By ID](http://localhost:4000/products?id=7) |
38 | | **Get All Tags** | `/tags` | [Local Tags](http://localhost:4000/tags) |
39 | | **Search by Tag** | `/products?[TagName]=[SearchItem]` | [Example](http://localhost:4000/products?tag=a) |
40 | | **Get All Brands** | `/brands` | [Local Brands](http://localhost:4000/brands) |
41 | | **Search by Brand** | `/products?[BrandName]=[SearchItem]` | [Example](http://localhost:4000/products?brand=a) |
42 |
43 | ---
44 |
45 | ## 🔧 Development Setup
46 |
47 | To start working with **Mrittik-Server**, follow these steps:
48 |
49 | ### 📥 Prerequisites
50 |
51 | 1. Install [Node.js](https://nodejs.org/en).
52 | 2. Install Yarn globally:
53 | ```bash
54 | npm install --global yarn
55 | ```
56 |
57 | ### 🛠 Clone the Repository
58 |
59 | ```bash
60 | git clone https://github.com/hbkabir004/Mrittik-Server.git
61 | ```
62 |
63 | ### ⚙️ Install Dependencies
64 |
65 | Navigate to the project folder in your terminal and run:
66 |
67 |
68 | ```bash
69 | yarn install
70 | ```
71 |
72 | ### 🚀 Start the Server
73 |
74 | Run the following command to start the development server:
75 |
76 |
77 | ```bash
78 | node index
79 | ```
80 |
81 |
82 | ### 🌟 Your local server is live at: [http://localhost:4000](http://localhost:4000)
83 |
84 | ---
85 |
86 | ## 🤝 Contributing
87 |
88 | We ❤️ contributions!
89 | Check out [CONTRIBUTING.md](https://github.com/hbkabir004/Mrittik-Server/blob/main/CONTRIBUTING.md) for details on how you can improve this project.
90 |
91 | ---
92 |
93 | ## 📢 Feedback
94 |
95 | Have questions or suggestions?
96 | Feel free to [open an issue](https://github.com/hbkabir004/Mrittik-Server/issues) or reach out with your feedback. Let's build something awesome together! 🌟
97 |
--------------------------------------------------------------------------------