Changeset 55ed171 for backend


Ignore:
Timestamp:
10/15/22 15:28:57 (2 years ago)
Author:
Nace Gjorgjievski <nace.gorgievski123@…>
Branches:
master
Children:
113029b
Parents:
ee05663
Message:

Full Admin Functionality Added

Location:
backend
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • backend/models/orderModel.js

    ree05663 r55ed171  
    3535    totalPrice: { type: Number, required: true },
    3636    user: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true },
     37    isConfirmed: { type: Boolean, default: false },
    3738    isPaid: { type: Boolean, default: false },
     39    contactNumber: { type: String },
    3840    paidAt: { type: Date },
    3941    paidAtFormat: { type: String },
     42    shippedAt: { type: Date },
     43    isShipped: { type: Boolean, default: false },
    4044    isDelivered: { type: Boolean, default: false },
    4145    deliveredAt: { type: Date },
  • backend/models/productModel.js

    ree05663 r55ed171  
    77    image: { type: String, required: true },
    88    sideImage: { type: String, required: true },
     9    sideImage2: { type: String, required: true },
    910    dimension: { type: String, required: true },
    1011    scheme: { type: String, required: true },
  • backend/package-lock.json

    ree05663 r55ed171  
    1515        "express-async-handler": "^1.2.0",
    1616        "jsonwebtoken": "^8.5.1",
    17         "mongoose": "^6.5.3"
     17        "mongoose": "^6.5.3",
     18        "multer": "^1.4.5-lts.1"
    1819      },
    1920      "devDependencies": {
     
    7071        "node": ">= 8"
    7172      }
     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=="
    7278    },
    7379    "node_modules/array-flatten": {
     
    199205      "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
    200206    },
     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    },
    201223    "node_modules/bytes": {
    202224      "version": "3.1.2",
     
    252274      "dev": true
    253275    },
     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    },
    254290    "node_modules/content-disposition": {
    255291      "version": "0.5.4",
     
    283319      "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
    284320      "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=="
    285326    },
    286327    "node_modules/debug": {
     
    636677      }
    637678    },
     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    },
    638684    "node_modules/jsonwebtoken": {
    639685      "version": "8.5.1",
     
    790836      }
    791837    },
     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    },
    792854    "node_modules/mongodb": {
    793855      "version": "4.8.1",
     
    886948      "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
    887949      "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      }
    888967    },
    889968    "node_modules/negotiator": {
     
    9631042      }
    9641043    },
     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    },
    9651052    "node_modules/object-inspect": {
    9661053      "version": "1.12.2",
     
    10071094      }
    10081095    },
     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    },
    10091101    "node_modules/proxy-addr": {
    10101102      "version": "2.0.7",
     
    10681160        "node": ">= 0.8"
    10691161      }
     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=="
    10701181    },
    10711182    "node_modules/readdirp": {
     
    12501361      }
    12511362    },
     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    },
    12521384    "node_modules/supports-color": {
    12531385      "version": "5.5.0",
     
    13161448        "node": ">= 0.6"
    13171449      }
     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=="
    13181455    },
    13191456    "node_modules/undefsafe": {
     
    13311468      }
    13321469    },
     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    },
    13331475    "node_modules/utils-merge": {
    13341476      "version": "1.0.1",
     
    13651507      "engines": {
    13661508        "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"
    13671517      }
    13681518    }
     
    14121562        "picomatch": "^2.0.4"
    14131563      }
     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=="
    14141569    },
    14151570    "array-flatten": {
     
    15001655      "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
    15011656    },
     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    },
    15021670    "bytes": {
    15031671      "version": "3.1.2",
     
    15361704      "dev": true
    15371705    },
     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    },
    15381717    "content-disposition": {
    15391718      "version": "0.5.4",
     
    15581737      "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
    15591738      "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=="
    15601744    },
    15611745    "debug": {
     
    18172001      "dev": true
    18182002    },
     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    },
    18192008    "jsonwebtoken": {
    18202009      "version": "8.5.1",
     
    19462135      "requires": {
    19472136        "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"
    19482150      }
    19492151    },
     
    20222224      "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
    20232225      "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      }
    20242240    },
    20252241    "negotiator": {
     
    20782294      "dev": true
    20792295    },
     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    },
    20802301    "object-inspect": {
    20812302      "version": "1.12.2",
     
    21072328      "dev": true
    21082329    },
     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    },
    21092335    "proxy-addr": {
    21102336      "version": "2.0.7",
     
    21492375        "iconv-lite": "0.4.24",
    21502376        "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        }
    21512398      }
    21522399    },
     
    22872534      "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ=="
    22882535    },
     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    },
    22892556    "supports-color": {
    22902557      "version": "5.5.0",
     
    23352602        "mime-types": "~2.1.24"
    23362603      }
     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=="
    23372609    },
    23382610    "undefsafe": {
     
    23472619      "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ=="
    23482620    },
     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    },
    23492626    "utils-merge": {
    23502627      "version": "1.0.1",
     
    23702647        "webidl-conversions": "^7.0.0"
    23712648      }
     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=="
    23722654    }
    23732655  }
  • backend/package.json

    ree05663 r55ed171  
    1717    "express-async-handler": "^1.2.0",
    1818    "jsonwebtoken": "^8.5.1",
    19     "mongoose": "^6.5.3"
     19    "mongoose": "^6.5.3",
     20    "multer": "^1.4.5-lts.1"
    2021  },
    2122  "devDependencies": {
  • backend/routes/orderRoutes.js

    ree05663 r55ed171  
    2121      isPaid: req.body.isPaid,
    2222      paidAt: req.body.paidAt,
     23      isConfirmed: req.body.isConfirmed,
     24      contactNumber: req.body.contactNumber,
    2325    });
    2426    const order = await newOrder.save();
     
    3335    const orders = await Order.find({ user: req.user._id });
    3436    res.send(orders);
     37  })
     38);
     39const PAGE_SIZE = 10;
     40orderRouter.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);
    3579  })
    3680);
     
    4993);
    5094
     95orderRouter.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
    51145export default orderRouter;
  • backend/routes/productRoutes.js

    ree05663 r55ed171  
    1 import express from "express";
     1import express, { query } from "express";
    22import Product from "../models/productModel.js";
     3import multer from "multer";
     4import expressAsyncHandler from "express-async-handler";
     5import userRouter from "./userRoutes.js";
    36
    47const productRouter = express.Router();
    58
     9const 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
     18const upload = multer({ storage: storage });
     19const 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]);
     26productRouter.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
     53const PAGE_SIZE = 20;
     54productRouter.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/*
    6101productRouter.get("/", async (req, res) => {
    7102  const products = await Product.find();
    8103  res.send(products);
    9104});
    10 
     105*/
    11106productRouter.get("/slug/:slug", async (req, res) => {
    12107  const product = await Product.findOne({ slug: req.params.slug });
     
    27122});
    28123
     124productRouter.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);
    29162export default productRouter;
Note: See TracChangeset for help on using the changeset viewer.