- Timestamp:
- 10/15/22 15:28:57 (2 years ago)
- Branches:
- master
- Children:
- 113029b
- Parents:
- ee05663
- Location:
- backend
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
backend/models/orderModel.js
ree05663 r55ed171 35 35 totalPrice: { type: Number, required: true }, 36 36 user: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true }, 37 isConfirmed: { type: Boolean, default: false }, 37 38 isPaid: { type: Boolean, default: false }, 39 contactNumber: { type: String }, 38 40 paidAt: { type: Date }, 39 41 paidAtFormat: { type: String }, 42 shippedAt: { type: Date }, 43 isShipped: { type: Boolean, default: false }, 40 44 isDelivered: { type: Boolean, default: false }, 41 45 deliveredAt: { type: Date }, -
backend/models/productModel.js
ree05663 r55ed171 7 7 image: { type: String, required: true }, 8 8 sideImage: { type: String, required: true }, 9 sideImage2: { type: String, required: true }, 9 10 dimension: { type: String, required: true }, 10 11 scheme: { type: String, required: true }, -
backend/package-lock.json
ree05663 r55ed171 15 15 "express-async-handler": "^1.2.0", 16 16 "jsonwebtoken": "^8.5.1", 17 "mongoose": "^6.5.3" 17 "mongoose": "^6.5.3", 18 "multer": "^1.4.5-lts.1" 18 19 }, 19 20 "devDependencies": { … … 70 71 "node": ">= 8" 71 72 } 73 }, 74 "node_modules/append-field": { 75 "version": "1.0.0", 76 "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", 77 "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" 72 78 }, 73 79 "node_modules/array-flatten": { … … 199 205 "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" 200 206 }, 207 "node_modules/buffer-from": { 208 "version": "1.1.2", 209 "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", 210 "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" 211 }, 212 "node_modules/busboy": { 213 "version": "1.6.0", 214 "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", 215 "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", 216 "dependencies": { 217 "streamsearch": "^1.1.0" 218 }, 219 "engines": { 220 "node": ">=10.16.0" 221 } 222 }, 201 223 "node_modules/bytes": { 202 224 "version": "3.1.2", … … 252 274 "dev": true 253 275 }, 276 "node_modules/concat-stream": { 277 "version": "1.6.2", 278 "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", 279 "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", 280 "engines": [ 281 "node >= 0.8" 282 ], 283 "dependencies": { 284 "buffer-from": "^1.0.0", 285 "inherits": "^2.0.3", 286 "readable-stream": "^2.2.2", 287 "typedarray": "^0.0.6" 288 } 289 }, 254 290 "node_modules/content-disposition": { 255 291 "version": "0.5.4", … … 283 319 "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 284 320 "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" 321 }, 322 "node_modules/core-util-is": { 323 "version": "1.0.3", 324 "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", 325 "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" 285 326 }, 286 327 "node_modules/debug": { … … 636 677 } 637 678 }, 679 "node_modules/isarray": { 680 "version": "1.0.0", 681 "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 682 "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" 683 }, 638 684 "node_modules/jsonwebtoken": { 639 685 "version": "8.5.1", … … 790 836 } 791 837 }, 838 "node_modules/minimist": { 839 "version": "1.2.6", 840 "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", 841 "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" 842 }, 843 "node_modules/mkdirp": { 844 "version": "0.5.6", 845 "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", 846 "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", 847 "dependencies": { 848 "minimist": "^1.2.6" 849 }, 850 "bin": { 851 "mkdirp": "bin/cmd.js" 852 } 853 }, 792 854 "node_modules/mongodb": { 793 855 "version": "4.8.1", … … 886 948 "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 887 949 "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" 950 }, 951 "node_modules/multer": { 952 "version": "1.4.5-lts.1", 953 "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", 954 "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", 955 "dependencies": { 956 "append-field": "^1.0.0", 957 "busboy": "^1.0.0", 958 "concat-stream": "^1.5.2", 959 "mkdirp": "^0.5.4", 960 "object-assign": "^4.1.1", 961 "type-is": "^1.6.4", 962 "xtend": "^4.0.0" 963 }, 964 "engines": { 965 "node": ">= 6.0.0" 966 } 888 967 }, 889 968 "node_modules/negotiator": { … … 963 1042 } 964 1043 }, 1044 "node_modules/object-assign": { 1045 "version": "4.1.1", 1046 "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 1047 "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", 1048 "engines": { 1049 "node": ">=0.10.0" 1050 } 1051 }, 965 1052 "node_modules/object-inspect": { 966 1053 "version": "1.12.2", … … 1007 1094 } 1008 1095 }, 1096 "node_modules/process-nextick-args": { 1097 "version": "2.0.1", 1098 "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", 1099 "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" 1100 }, 1009 1101 "node_modules/proxy-addr": { 1010 1102 "version": "2.0.7", … … 1068 1160 "node": ">= 0.8" 1069 1161 } 1162 }, 1163 "node_modules/readable-stream": { 1164 "version": "2.3.7", 1165 "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", 1166 "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", 1167 "dependencies": { 1168 "core-util-is": "~1.0.0", 1169 "inherits": "~2.0.3", 1170 "isarray": "~1.0.0", 1171 "process-nextick-args": "~2.0.0", 1172 "safe-buffer": "~5.1.1", 1173 "string_decoder": "~1.1.1", 1174 "util-deprecate": "~1.0.1" 1175 } 1176 }, 1177 "node_modules/readable-stream/node_modules/safe-buffer": { 1178 "version": "5.1.2", 1179 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 1180 "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 1070 1181 }, 1071 1182 "node_modules/readdirp": { … … 1250 1361 } 1251 1362 }, 1363 "node_modules/streamsearch": { 1364 "version": "1.1.0", 1365 "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", 1366 "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", 1367 "engines": { 1368 "node": ">=10.0.0" 1369 } 1370 }, 1371 "node_modules/string_decoder": { 1372 "version": "1.1.1", 1373 "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", 1374 "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", 1375 "dependencies": { 1376 "safe-buffer": "~5.1.0" 1377 } 1378 }, 1379 "node_modules/string_decoder/node_modules/safe-buffer": { 1380 "version": "5.1.2", 1381 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 1382 "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 1383 }, 1252 1384 "node_modules/supports-color": { 1253 1385 "version": "5.5.0", … … 1316 1448 "node": ">= 0.6" 1317 1449 } 1450 }, 1451 "node_modules/typedarray": { 1452 "version": "0.0.6", 1453 "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", 1454 "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" 1318 1455 }, 1319 1456 "node_modules/undefsafe": { … … 1331 1468 } 1332 1469 }, 1470 "node_modules/util-deprecate": { 1471 "version": "1.0.2", 1472 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 1473 "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" 1474 }, 1333 1475 "node_modules/utils-merge": { 1334 1476 "version": "1.0.1", … … 1365 1507 "engines": { 1366 1508 "node": ">=12" 1509 } 1510 }, 1511 "node_modules/xtend": { 1512 "version": "4.0.2", 1513 "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", 1514 "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", 1515 "engines": { 1516 "node": ">=0.4" 1367 1517 } 1368 1518 } … … 1412 1562 "picomatch": "^2.0.4" 1413 1563 } 1564 }, 1565 "append-field": { 1566 "version": "1.0.0", 1567 "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", 1568 "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" 1414 1569 }, 1415 1570 "array-flatten": { … … 1500 1655 "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" 1501 1656 }, 1657 "buffer-from": { 1658 "version": "1.1.2", 1659 "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", 1660 "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" 1661 }, 1662 "busboy": { 1663 "version": "1.6.0", 1664 "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", 1665 "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", 1666 "requires": { 1667 "streamsearch": "^1.1.0" 1668 } 1669 }, 1502 1670 "bytes": { 1503 1671 "version": "3.1.2", … … 1536 1704 "dev": true 1537 1705 }, 1706 "concat-stream": { 1707 "version": "1.6.2", 1708 "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", 1709 "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", 1710 "requires": { 1711 "buffer-from": "^1.0.0", 1712 "inherits": "^2.0.3", 1713 "readable-stream": "^2.2.2", 1714 "typedarray": "^0.0.6" 1715 } 1716 }, 1538 1717 "content-disposition": { 1539 1718 "version": "0.5.4", … … 1558 1737 "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 1559 1738 "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" 1739 }, 1740 "core-util-is": { 1741 "version": "1.0.3", 1742 "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", 1743 "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" 1560 1744 }, 1561 1745 "debug": { … … 1817 2001 "dev": true 1818 2002 }, 2003 "isarray": { 2004 "version": "1.0.0", 2005 "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 2006 "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" 2007 }, 1819 2008 "jsonwebtoken": { 1820 2009 "version": "8.5.1", … … 1946 2135 "requires": { 1947 2136 "brace-expansion": "^1.1.7" 2137 } 2138 }, 2139 "minimist": { 2140 "version": "1.2.6", 2141 "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", 2142 "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" 2143 }, 2144 "mkdirp": { 2145 "version": "0.5.6", 2146 "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", 2147 "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", 2148 "requires": { 2149 "minimist": "^1.2.6" 1948 2150 } 1949 2151 }, … … 2022 2224 "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 2023 2225 "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" 2226 }, 2227 "multer": { 2228 "version": "1.4.5-lts.1", 2229 "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", 2230 "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", 2231 "requires": { 2232 "append-field": "^1.0.0", 2233 "busboy": "^1.0.0", 2234 "concat-stream": "^1.5.2", 2235 "mkdirp": "^0.5.4", 2236 "object-assign": "^4.1.1", 2237 "type-is": "^1.6.4", 2238 "xtend": "^4.0.0" 2239 } 2024 2240 }, 2025 2241 "negotiator": { … … 2078 2294 "dev": true 2079 2295 }, 2296 "object-assign": { 2297 "version": "4.1.1", 2298 "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 2299 "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" 2300 }, 2080 2301 "object-inspect": { 2081 2302 "version": "1.12.2", … … 2107 2328 "dev": true 2108 2329 }, 2330 "process-nextick-args": { 2331 "version": "2.0.1", 2332 "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", 2333 "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" 2334 }, 2109 2335 "proxy-addr": { 2110 2336 "version": "2.0.7", … … 2149 2375 "iconv-lite": "0.4.24", 2150 2376 "unpipe": "1.0.0" 2377 } 2378 }, 2379 "readable-stream": { 2380 "version": "2.3.7", 2381 "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", 2382 "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", 2383 "requires": { 2384 "core-util-is": "~1.0.0", 2385 "inherits": "~2.0.3", 2386 "isarray": "~1.0.0", 2387 "process-nextick-args": "~2.0.0", 2388 "safe-buffer": "~5.1.1", 2389 "string_decoder": "~1.1.1", 2390 "util-deprecate": "~1.0.1" 2391 }, 2392 "dependencies": { 2393 "safe-buffer": { 2394 "version": "5.1.2", 2395 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 2396 "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 2397 } 2151 2398 } 2152 2399 }, … … 2287 2534 "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" 2288 2535 }, 2536 "streamsearch": { 2537 "version": "1.1.0", 2538 "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", 2539 "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==" 2540 }, 2541 "string_decoder": { 2542 "version": "1.1.1", 2543 "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", 2544 "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", 2545 "requires": { 2546 "safe-buffer": "~5.1.0" 2547 }, 2548 "dependencies": { 2549 "safe-buffer": { 2550 "version": "5.1.2", 2551 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 2552 "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 2553 } 2554 } 2555 }, 2289 2556 "supports-color": { 2290 2557 "version": "5.5.0", … … 2335 2602 "mime-types": "~2.1.24" 2336 2603 } 2604 }, 2605 "typedarray": { 2606 "version": "0.0.6", 2607 "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", 2608 "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" 2337 2609 }, 2338 2610 "undefsafe": { … … 2347 2619 "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==" 2348 2620 }, 2621 "util-deprecate": { 2622 "version": "1.0.2", 2623 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 2624 "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" 2625 }, 2349 2626 "utils-merge": { 2350 2627 "version": "1.0.1", … … 2370 2647 "webidl-conversions": "^7.0.0" 2371 2648 } 2649 }, 2650 "xtend": { 2651 "version": "4.0.2", 2652 "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", 2653 "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" 2372 2654 } 2373 2655 } -
backend/package.json
ree05663 r55ed171 17 17 "express-async-handler": "^1.2.0", 18 18 "jsonwebtoken": "^8.5.1", 19 "mongoose": "^6.5.3" 19 "mongoose": "^6.5.3", 20 "multer": "^1.4.5-lts.1" 20 21 }, 21 22 "devDependencies": { -
backend/routes/orderRoutes.js
ree05663 r55ed171 21 21 isPaid: req.body.isPaid, 22 22 paidAt: req.body.paidAt, 23 isConfirmed: req.body.isConfirmed, 24 contactNumber: req.body.contactNumber, 23 25 }); 24 26 const order = await newOrder.save(); … … 33 35 const orders = await Order.find({ user: req.user._id }); 34 36 res.send(orders); 37 }) 38 ); 39 const PAGE_SIZE = 10; 40 orderRouter.get( 41 "/", 42 expressAsyncHandler(async (req, res) => { 43 const { query } = req; 44 const pageSize = query.pageSize || PAGE_SIZE; 45 const page = query.page || 1; 46 const isConfirmed = query.isConfirmed || ""; 47 const isShipped = query.isShipped || ""; 48 const searchQuery = query.query || ""; 49 const isDelivered = false; 50 const queryFilter = 51 searchQuery && searchQuery !== "all" 52 ? { _: { $regex: searchQuery, $options: "i" } } 53 : {}; 54 const isConfirmedFilter = 55 isConfirmed && isConfirmed !== "all" ? { isConfirmed } : {}; 56 const isShippedFilter = 57 isShipped && isShipped !== "all" ? { isShipped } : {}; 58 59 const orders = await Order.find({ 60 ...queryFilter, 61 ...isConfirmedFilter, 62 ...isShippedFilter, 63 ...isDelivered, 64 }) 65 .skip(pageSize * (page - 1)) 66 .limit(pageSize); 67 const countOrders = await Order.countDocuments({ 68 ...isConfirmedFilter, 69 ...isShippedFilter, 70 }); 71 res.send({ 72 orders, 73 countOrders, 74 page, 75 pages: Math.ceil(countOrders / pageSize), 76 }); 77 //const orders = await Order.find(); 78 //res.send(orders); 35 79 }) 36 80 ); … … 49 93 ); 50 94 95 orderRouter.put( 96 "/action", 97 expressAsyncHandler(async (req, res) => { 98 if (req.body.isConfirmed) { 99 const order = await Order.updateOne( 100 { _id: req.body._id }, 101 { 102 $set: { 103 isConfirmed: req.body.isConfirmed, 104 }, 105 } 106 ); 107 } else if (req.body.isShipped) { 108 const order = await Order.updateOne( 109 { _id: req.body._id }, 110 { 111 $set: { 112 isShipped: req.body.isShipped, 113 shippedAt: req.body.shippedAt, 114 }, 115 } 116 ); 117 } else if (req.body.isDelivered && req.body.isPaid) { 118 const order = await Order.updateOne( 119 { _id: req.body._id }, 120 { 121 $set: { 122 isDelivered: req.body.isDelivered, 123 deliveredAt: req.body.deliveredAt, 124 isPaid: req.body.isPaid, 125 paidAt: req.body.paidAt, 126 }, 127 } 128 ); 129 } else { 130 const order = await Order.updateOne( 131 { _id: req.body._id }, 132 { 133 $set: { 134 isDelivered: req.body.isDelivered, 135 deliveredAt: req.body.deliveredAt, 136 }, 137 } 138 ); 139 } 140 141 res.status(200).send({ message: "Succesful" }); 142 }) 143 ); 144 51 145 export default orderRouter; -
backend/routes/productRoutes.js
ree05663 r55ed171 1 import express from "express";1 import express, { query } from "express"; 2 2 import Product from "../models/productModel.js"; 3 import multer from "multer"; 4 import expressAsyncHandler from "express-async-handler"; 5 import userRouter from "./userRoutes.js"; 3 6 4 7 const productRouter = express.Router(); 5 8 9 const storage = multer.diskStorage({ 10 destination: (req, file, callback) => { 11 callback(null, "../frontend/public/uploads/"); 12 }, 13 filename: (req, file, callback) => { 14 callback(null, file.originalname); 15 }, 16 }); 17 18 const upload = multer({ storage: storage }); 19 const multipleUpload = upload.fields([ 20 { name: "image", maxCount: 1 }, 21 { name: "sideImage", maxCount: 1 }, 22 { name: "sideImage2", maxCount: 1 }, 23 { name: "dimension", maxCount: 1 }, 24 { name: "scheme", maxCount: 1 }, 25 ]); 26 productRouter.post( 27 "/add", 28 multipleUpload, 29 expressAsyncHandler(async (req, res) => { 30 const newProduct = new Product({ 31 name: req.body.name, 32 slug: req.body.slug, 33 image: `/uploads/${req.files.image[0].originalname}`, 34 sideImage: `/uploads/${req.files.sideImage[0].originalname}`, 35 sideImage2: `/uploads/${req.files.sideImage2[0].originalname}`, 36 dimension: `/uploads/${req.files.dimension[0].originalname}`, 37 scheme: `/uploads/${req.files.scheme[0].originalname}`, 38 category: req.body.category, 39 subCategory: req.body.subCategory, 40 description: req.body.description, 41 price: req.body.price, 42 priceMontaza: req.body.priceMontaza, 43 countInStock: req.body.countInStock, 44 }); 45 46 const product = await newProduct.save(); 47 if (product) 48 res.status(201).send({ message: "New Product Created", product }); 49 else res.status(404).send({ message: "Error creating product" }); 50 }) 51 ); 52 53 const PAGE_SIZE = 20; 54 productRouter.get( 55 "/", 56 expressAsyncHandler(async (req, res) => { 57 const { query } = req; 58 const pageSize = query.pageSize || PAGE_SIZE; 59 const page = query.page || 1; 60 const category = query.category || ""; 61 const subCategory = query.subCategory || ""; 62 const order = query.order || ""; 63 const searchQuery = query.query || ""; 64 65 const queryFilter = 66 searchQuery && searchQuery !== "all" 67 ? { name: { $regex: searchQuery, $options: "i" } } 68 : {}; 69 const categoryFilter = category && category !== "all" ? { category } : {}; 70 const subCategoryFilter = 71 subCategory && subCategory !== "all" ? { subCategory } : {}; 72 const sortOrder = 73 order === "lowFirst" 74 ? { price: 1 } 75 : order === "highFirst" 76 ? { price: -1 } 77 : { createdAt: -1 }; 78 const products = await Product.find({ 79 ...queryFilter, 80 ...categoryFilter, 81 ...subCategoryFilter, 82 }) 83 .sort(sortOrder) 84 .skip(pageSize * (page - 1)) 85 .limit(pageSize); 86 87 const countProducts = await Product.countDocuments({ 88 ...queryFilter, 89 ...categoryFilter, 90 ...subCategoryFilter, 91 }); 92 res.send({ 93 products, 94 countProducts, 95 page, 96 pages: Math.ceil(countProducts / pageSize), 97 }); 98 }) 99 ); 100 /* 6 101 productRouter.get("/", async (req, res) => { 7 102 const products = await Product.find(); 8 103 res.send(products); 9 104 }); 10 105 */ 11 106 productRouter.get("/slug/:slug", async (req, res) => { 12 107 const product = await Product.findOne({ slug: req.params.slug }); … … 27 122 }); 28 123 124 productRouter.put( 125 "/edit", 126 expressAsyncHandler(async (req, res) => { 127 const product = await Product.updateOne( 128 { slug: req.body.slug }, 129 { 130 $set: { 131 name: req.body.name, 132 category: req.body.category, 133 slug: req.body.slug, 134 subCategory: req.body.subCategory, 135 description: req.body.description, 136 price: req.body.price, 137 priceMontaza: req.body.priceMontaza, 138 countInStock: req.body.countInStock, 139 }, 140 } 141 ); 142 /* 143 if (product) { 144 product.name = req.body.name || product.name; 145 product.slug = req.body.slug || product.slug; 146 product.price = req.body.price || product.price; 147 product.category = req.body.category || product.category; 148 product.subCategory = req.body.subCategory || product.subCategory; 149 product.description = req.body.description || product.description; 150 product.priceMontaza = req.body.priceMontaza || product.priceMontaza; 151 product.countInStock = req.body.countInStock || product.countInStock; 152 product.image = product.image; 153 product.sideImage = product.sideImage2; 154 product.sideImage2 = product.sideImage2; 155 156 const updatedProduct = await product.save();*/ 157 res.status(200).send({ message: "Succesful" }); 158 //else { 159 //res.status(404).send({ message: "Product Not Found" }); 160 }) 161 ); 29 162 export default productRouter;
Note:
See TracChangeset
for help on using the changeset viewer.