diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..b0ab4e5bc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "prettier.singleQuote": true, + "editor.formatOnType": true +} \ No newline at end of file diff --git a/back/package-lock.json b/back/package-lock.json index 061fb4bd2..4c3c55c52 100644 --- a/back/package-lock.json +++ b/back/package-lock.json @@ -1,8 +1,542 @@ { "name": "kanap-backend", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "kanap-backend", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "express": "^4.16.4", + "uuid": "^3.3.2" + } + }, + "node_modules/accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "dependencies": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "node_modules/body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "dependencies": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/body-parser/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/body-parser/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node_modules/bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "dependencies": { + "safe-buffer": "5.1.2" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "dependencies": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/express/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/express/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node_modules/finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/finalhandler/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/finalhandler/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node_modules/forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/http-errors/node_modules/inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.47.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", + "integrity": "sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.30", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.30.tgz", + "integrity": "sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==", + "dependencies": { + "mime-db": "1.47.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "node_modules/proxy-addr": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", + "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", + "dependencies": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "dependencies": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "dependencies": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/send/node_modules/debug/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + }, + "node_modules/serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, + "node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "bin": { + "uuid": "bin/uuid" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "engines": { + "node": ">= 0.8" + } + } + }, "dependencies": { "accepts": { "version": "1.3.7", diff --git a/front/html/index.html b/front/html/index.html index 209ee5d30..c9eaed37e 100644 --- a/front/html/index.html +++ b/front/html/index.html @@ -83,6 +83,6 @@

Kanap name1

- + \ No newline at end of file diff --git a/front/js/cart.js b/front/js/cart.js new file mode 100644 index 000000000..3e2d27a62 --- /dev/null +++ b/front/js/cart.js @@ -0,0 +1,375 @@ +// -------------------------------------------------------------- +fetch('http://localhost:3000/api/products') + .then(function (res) { + if (res.ok) { + return res.json(); + } + }) + .then(function (cart) { + // -------------------------------------------------------------- + // Fonction pour afficher les produits dans la page panier + if (localStorage.getItem('products') != null) { + let basket = JSON.parse(localStorage.getItem('products')); + // Boucle pour afficher les produits dans le panier + basket.forEach(function (product) { + cart.find((canap)=>{ + if (canap._id == product._id) { + const article = document + .querySelector('#cart__items') + .appendChild(document.createElement('article')); + article.setAttribute('class', 'cart__item'); + article.setAttribute('data-id', canap._id); + article.setAttribute('data-color', product.color); + // Afficher les images + const divImg = article.appendChild(document.createElement('div')); + divImg.setAttribute('class', 'cart__item__img'); + let img = divImg.appendChild(document.createElement('img')); + img.setAttribute('src', product.img); + img.setAttribute('alt', product.alt); + // Afficher div container + const divContent = article.appendChild( + document.createElement('div') + ); + divContent.setAttribute('class', 'cart__item__content'); + // Afficher div description + let divContentDescr = divContent.appendChild( + document.createElement('div') + ); + divContentDescr.setAttribute( + 'class', + 'cart__item__content__description' + ); + // Afficher titre - couleur - prix + let titre = divContentDescr.appendChild( + document.createElement('h2') + ); + titre.innerText = canap.name; + let clr = divContentDescr.appendChild(document.createElement('p')); + clr.innerText = product.color; + // prix total en fonction de la quantité + let totalProductPrice = canap.price * product.quantity; + + let price = divContentDescr.appendChild( + document.createElement('p') + ); + price.innerText = totalProductPrice + ' €'; + // Afficher div settings + const divContentSett = divContent.appendChild( + document.createElement('div') + ); + divContentSett.setAttribute( + 'class', + 'cart__item__content__settings' + ); + const divContentSettQnt = divContentSett.appendChild( + document.createElement('div') + ); + // Afficher quantité + divContentSettQnt.setAttribute( + 'class', + 'cart__item__content__settings__quantity' + ); + let qte = divContentSettQnt.appendChild( + document.createElement('p') + ); + qte.innerText = 'Qté : '; + let input = divContentSettQnt.appendChild( + document.createElement('input') + ); + input.setAttribute('type', 'number'); + input.setAttribute('class', 'itemQuantity'); + input.setAttribute('name', 'itemQuantity'); + input.setAttribute('min', 1); + input.setAttribute('max', 100); + input.setAttribute('value', product.quantity); + + // Afficher bouton supprimer + const divContentSettDlt = divContentSett.appendChild( + document.createElement('div') + ); + divContentSettDlt.setAttribute( + 'class', + 'cart__item__content__settings__delete' + ); + let deleteItem = divContentSettDlt.appendChild( + document.createElement('p') + ); + deleteItem.setAttribute('class', 'deleteItem'); + deleteItem.innerText = 'Supprimer'; + } + }) + }); + + } else { + alert('Le panier est vide!'); + } + totalCartQuantity(); /*totale quantité */ + totalProductPrice(); /**totale prix */ + changeQuantity(); /**changer quantité */ + deleteProduct(); /**supprimer article */ + }) + .catch(function () { + alert('Une erreur est survenue'); + }); + + + +// ----------------------------------------------------------- +// Affiche total quantité produits dans le panier +function totalCartQuantity() { + let item = document.getElementsByClassName('cart__item'); + let totalQuantity = 0; + for (itemQuantity of item) { + totalQuantity += parseInt(itemQuantity.querySelector('.itemQuantity').value); + if (totalQuantity > 100) { + alert('Le panier ne peut pas contenir plus de 100 articles! Merci de supprimer certains articles'); + return; + } + } + document.querySelector('#totalQuantity').innerText = totalQuantity; +} + + + +// ----------------------------------------------------------- +// Afficher le prix total +function totalProductPrice() { + let itemPrice = document.getElementsByClassName('cart__item'); + let totalPrice = 0; + for (item of itemPrice) { + totalPrice += parseInt( + item.querySelector('.cart__item__content__description').children[2] + .innerText + ); + } + document.querySelector('#totalPrice').innerText = totalPrice; +} + + + +// ------------------------------------------------------------- +// Fonction pour changer la quantité +function changeQuantity() { + const newQuantity = document.querySelectorAll('.cart__item'); + newQuantity.forEach((change) => { + const id = change.closest('article').getAttribute('data-id'); + const color = change.closest('article').getAttribute('data-color'); + // Event pour changer la quantité + change.addEventListener('change', (el) => { + let basket = JSON.parse(localStorage.getItem('products')); + for (qt of basket) { + if (qt._id == id && qt.color == color) { + // On change la quantité dans le ls avec le nouveau input + qt.quantity = el.target.value; + if (qt.quantity > 0 && qt.quantity <= 100) { + localStorage.products = JSON.stringify(basket); + window.location.reload(); + totalCartQuantity(); + totalProductPrice(); + } else { + alert("La quantité ajouté n'est pas valide"); + window.location.reload(); + } + } + } + }); + }); +} + + + + +// ------------------------------------------------------------- +// Fonction pour supprimer un article +function deleteProduct() { + const btns = document.querySelectorAll('.deleteItem'); + btns.forEach((btn) => { + const article = btn.closest('article'); + btn.addEventListener('click', () => { + let basket = JSON.parse(localStorage.getItem('products')); + for (let i = 0; i < basket.length; i++) { + if ( + article.dataset.id == basket[i]._id && + article.dataset.color == basket[i].color + ) { + document.querySelector('#cart__items').removeChild(article); + basket.splice(i, 1); + localStorage.products = JSON.stringify(basket); + window.location.reload(); + if (i <= 0) { + localStorage.removeItem('products', JSON.stringify(basket)); + alert('Le panier est vide!'); + } + } + } + + alert( `Le produit a été supprimé avec succès!`); + totalCartQuantity(); + totalProductPrice(); + }); + }); +} + + + + +// --------------------------------------------------------------------- +// -----------------------Formulaire------------------------------------ + +// RegExp +const regExpName = new RegExp("^[A-Za-z- -']+$"); +const regExpEmail = new RegExp ('^[a-zA-Z0-9.-_]+[@][a-zA-Z0-9.-_]+[.]{1}[a-z]{2,6}$'); +const regExpAdress = new RegExp("^[0-9a-zA-Zà-ùÀ-Ù- -']+$"); + + + +// Elements +const firstName = document.getElementById('firstName'); +const lastName = document.getElementById('lastName'); +const address = document.getElementById('address'); +const city = document.getElementById('city'); +const email = document.getElementById('email'); + +const firstNameErrorMsg = document.getElementById('firstNameErrorMsg'); +const lastNameErrorMsg = document.getElementById('lastNameErrorMsg'); +const addressErrorMsg = document.getElementById('addressErrorMsg'); +const cityErrorMsg = document.getElementById('cityErrorMsg'); +const emailErrorMsg = document.getElementById('emailErrorMsg'); + + + +// *********************Fonctions***************************** + + +// Fonction pour valider la saisie du prénom +function validateFirstName() { + if (regExpName.test(firstName.value)) { + firstName.style.backgroundColor = 'lightgreen'; + return true; + } + else { + firstNameErrorMsg.innerText = 'Veuillez saisir un prénom valide!'; + firstName.style.backgroundColor = '#fbbcbc'; + } +} + +// Fonction pour valider la saisie du nom +function validateLastName() { + if (regExpName.test(lastName.value)) { + lastName.style.backgroundColor = 'lightgreen'; + return true; + } + else { + lastNameErrorMsg.innerText = 'Veuillez saisir un nom valide!'; + lastName.style.backgroundColor = '#fbbcbc'; + } +} + +// Fonction pour valider la saisie de l'adresse +function validateAddress() { + if (regExpAdress.test(address.value)) { + address.style.backgroundColor = 'lightgreen'; + return true; + } + else { + addressErrorMsg.innerText = 'Veuillez saisir une adresse valide!'; + address.style.backgroundColor = '#fbbcbc'; + } +} + +// Fonction pour valider la saisie de la ville +function validateCity() { + if (regExpAdress.test(city.value)) { + city.style.backgroundColor = 'lightgreen'; + return true; + } + else { + cityErrorMsg.innerText = 'Veuillez saisir une ville valide!'; + city.style.backgroundColor = '#fbbcbc'; + } +} + +// Fonction pour valider la saisie de l'email +function validateEmail() { + if (regExpEmail.test(email.value)) { + email.style.backgroundColor = 'lightgreen'; + return true; + } + else { + emailErrorMsg.innerText = 'Veuillez saisir une adresse électronique valide!'; + email.style.backgroundColor = '#fbbcbc'; + + } +} + + + +// Fonction pour envoyer le formulaire +function orderCart() { + const order = document.getElementById('order'); + order.addEventListener('click', (event) => { + event.preventDefault(); + // Si la saisie du formulaire est ok + if (validateFirstName() && validateLastName() && validateAddress() && validateCity() && validateEmail()) { + getOrderId(); + } else { + // Message d'erreur + alert('Merci de vérifier les informations saisie'); + return; + } + }); +} +orderCart(); + + +// Fonction pour collecter les produits dans le panier +function getOrderId() { + // Objet Contacts + const contact = { + firstName: firstName.value, + lastName: lastName.value, + address: address.value, + city: city.value, + email: email.value + } + localStorage.setItem('contacts', JSON.stringify(contact)); + // Création array basket avec les produits dans le panier + const basket = JSON.parse(localStorage.getItem('products')); + const product = []; + if (basket !== null) { + basket.forEach(item => { + product.push(item._id); + }); + } else { + alert('Impossible de passer la commande, le panier est vide!'); + return; + } + + // Fonction pour récup le orderId + function orderId() { + // Objet avec contacts et basket + let postJson = { + contact: contact, + products: product, + }; + const fetchOrderId = fetch('http://localhost:3000/api/products/order', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(postJson), + }) + .then(function (res) { + return res.json(); + }) + .then(function (reponse) { + // On recupère le orderId + document.location.href = `confirmation.html?id=${reponse.orderId}`; + }) + .catch(function () { + alert('Une erreur est survenue'); + }); + fetchOrderId; + } + orderId(); +} diff --git a/front/js/confirmation.js b/front/js/confirmation.js new file mode 100644 index 000000000..0a6e8b962 --- /dev/null +++ b/front/js/confirmation.js @@ -0,0 +1,12 @@ + +// On cherche le orderId dans le urlsp +const newUrl = new URLSearchParams(window.location.search); +const confirmationNumber = newUrl.get('id'); + +// Fonction pour afficher le numéro de commande +function orderNumber(){ + document.getElementById('orderId').innerText = confirmationNumber; + alert('Commande validée avec succès!'); + localStorage.clear(); +} +orderNumber(); diff --git a/front/js/fetch.js b/front/js/fetch.js new file mode 100644 index 000000000..552e61cbc --- /dev/null +++ b/front/js/fetch.js @@ -0,0 +1,16 @@ +// -------------------------------------------- +// Fonction générale pour fetch les produits +export function fetchAllProducts(displayAllProducts) { + fetch('http://localhost:3000/api/products') + .then(function (res) { + if (res.ok) { + return res.json(); + } + }) + .then(displayAllProducts) + .catch(function () { + alert('Une erreur est survenue'); + }); +} + + diff --git a/front/js/product.js b/front/js/product.js new file mode 100644 index 000000000..e812b8207 --- /dev/null +++ b/front/js/product.js @@ -0,0 +1,108 @@ + +// ---------------------------------------------------------- +// URLSerachParams pour selectionner les produits par leur ID +const params = new URLSearchParams(window.location.search); +const id = params.get('id'); + + + +// ------------------------------------------------- +// Fetch pour recuperer l'API + ID du produit +fetch(`http://localhost:3000/api/products/${id}`) + .then(function (res) { + if (res.ok) { + return res.json(); + } + }) + .then(displaySelectedProduct) + .catch(function () { + alert('Une erreur est survenue'); + }); + + + + + // ------------------------------------------------- + // Fonction pour afficher le produit +function displaySelectedProduct(item) { + // Creation balise image avec ses attributs + const content = document.createElement('img'); + content.setAttribute('src', item.imageUrl); + content.setAttribute('alt', item.altTxt); + document.querySelector('.item__img').appendChild(content); + + // Creation title price et description + document.getElementById('title').innerText = item.name; + document.getElementById('price').innerText = item.price; + document.getElementById('description').innerText = item.description; + + // Boucle choix couleur + const colors = item.colors; + colors.forEach((color) => { + let createColors = document.createElement('option'); + createColors.setAttribute('value', `${color}`); + createColors.innerText = `${color}`; + document.querySelector('#colors').appendChild(createColors); + }); + + // Ajout quantite 1 + let quantityCart = document.getElementById('quantity'); + quantityCart.setAttribute('value', '1'); + + // ************************* CART ******************** + const addToCart = document.querySelector('#addToCart'); + // Ecouter le click + addToCart.addEventListener('click', function () { + // Objets selectionnes + const product = { + img: item.imageUrl, + alt: item.altTxt, + name: item.name, + _id: item._id, + color: document.querySelector('#colors').value, + quantity: parseInt(document.getElementById('quantity').value), + }; + let basket = []; + // Définir messages erreur/saisie non valide + if ( + product.color == '' || + product.quantity > 100 || + product.quantity == 0 + ) { + alert('Merci de choisir une couleur et/ou quantité valide'); + } else { + if (localStorage.getItem('products') != null) { + basket = JSON.parse(localStorage.getItem('products')); + let foundProduct = true; + let quantityFoundProduct = 0; + basket.forEach((i) => { + //boucle foreach pour retrouver dans le ls le produit avec même id/couleur + if (i._id == product._id && i.color == product.color) { + quantityFoundProduct = parseInt(i.quantity); + // si il y a un produit avec le même id et couleur + const totalQuantity = parseInt(i.quantity) + product.quantity; + if (totalQuantity > 100) { + foundProduct = false; + alert('Le panier ne peut pas contenir plus de 100 articles'); + window.location.reload(); + return; + } + } + }); + // si la condition foundProduct est vrai on push le produit dans basket + if (foundProduct) { + product.quantity = product.quantity + quantityFoundProduct; + basket.push(product); + alert(`${quantityCart.value} "${item.name}" en couleur "${product.color}" ajouté au panier!`); + } + } else { + // si le produit n'existe pas dans le ls + basket.push(product); + alert(`${quantityCart.value} "${item.name}" en couleur "${product.color}" ajouté au panier!`); + } + } + // on definie le LocalStorage + localStorage.setItem('products', JSON.stringify(basket)); + }); + +} diff --git a/front/js/script.js b/front/js/script.js new file mode 100644 index 000000000..2d098310d --- /dev/null +++ b/front/js/script.js @@ -0,0 +1,25 @@ +// -------------------------------------------------------------- +// Je importe la fonction dans le fichier fetch.js +import { fetchAllProducts } from './fetch.js' + + +// -------------------------------------------------------------- +// Fonction pour afficher tous les produits dans la page d'accueil +function displayAllProducts(products) { + // Creer constante pour afficher les elements dans #items + const insertItem = document.querySelector('#items'); + // Boucle pour afficher les cards produits + for (let item of products) { + let element = document.createElement('a'); + element.setAttribute('href', `./product.html?id=${item._id}`); + // Inserer elements avec DOM + element.innerHTML = `
+ ${item.altTxt}/> 
+        <h3 class=${item.name} +

${item.description}

+
`; + // Afficher les produits + insertItem.append(element); + } +} +fetchAllProducts(displayAllProducts); \ No newline at end of file