diff --git a/nodemon.json b/nodemon.json new file mode 100644 index 0000000..bddbd78 --- /dev/null +++ b/nodemon.json @@ -0,0 +1,7 @@ +{ + "watch": [ + "src" + ], + "ext": "ts, json", + "exec": "npm run ts ./src/main.rest.ts | pino-pretty --colorize --translateTime SYS:standard" +} diff --git a/package-lock.json b/package-lock.json index d5b81af..183f413 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "eslint": "8.49.0", "eslint-config-htmlacademy": "9.1.1", "json-server": "0.17.3", + "nodemon": "3.1.7", "pino-pretty": "11.2.2", "rimraf": "5.0.1", "ts-node": "10.9.2", @@ -806,6 +807,19 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -1043,6 +1057,18 @@ "node": ">= 0.8" } }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/body-parser": { "version": "1.20.3", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", @@ -1229,6 +1255,42 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/ci-info": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", @@ -3050,6 +3112,20 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -3492,6 +3568,12 @@ "node": ">= 4" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -3619,6 +3701,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/is-boolean-object": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", @@ -4716,6 +4810,55 @@ "node": ">= 0.6" } }, + "node_modules/nodemon": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz", + "integrity": "sha512-hLj7fuMow6f0lbB0cD14Lz2xNjwsyruH251Pk4t/yIitCFJbmY1myuLlHm/q06aST4jg6EgAh74PIBBrRqpVAQ==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/nodemon/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -4737,6 +4880,15 @@ "semver": "bin/semver" } }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/normalize-url": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-8.0.1.tgz", @@ -5301,6 +5453,12 @@ "node": ">= 0.10" } }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, "node_modules/pump": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", @@ -5517,6 +5675,18 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/real-require": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", @@ -5972,6 +6142,18 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -6415,6 +6597,15 @@ "node": ">=0.6" } }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, "node_modules/tr46": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz", @@ -6636,6 +6827,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", @@ -7560,6 +7757,16 @@ "color-convert": "^2.0.1" } }, + "anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, "arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -7723,6 +7930,12 @@ "safe-buffer": "5.1.2" } }, + "binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true + }, "body-parser": { "version": "1.20.3", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", @@ -7857,6 +8070,33 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==" }, + "chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "dependencies": { + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + } + } + }, "ci-info": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", @@ -9211,6 +9451,13 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, + "fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "optional": true + }, "function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -9511,6 +9758,12 @@ "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", "dev": true }, + "ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, "import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -9605,6 +9858,15 @@ "has-bigints": "^1.0.1" } }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, "is-boolean-object": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", @@ -10366,6 +10628,41 @@ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", "dev": true }, + "nodemon": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz", + "integrity": "sha512-hLj7fuMow6f0lbB0cD14Lz2xNjwsyruH251Pk4t/yIitCFJbmY1myuLlHm/q06aST4jg6EgAh74PIBBrRqpVAQ==", + "dev": true, + "requires": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "dependencies": { + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -10386,6 +10683,12 @@ } } }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, "normalize-url": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-8.0.1.tgz", @@ -10798,6 +11101,12 @@ "ipaddr.js": "1.9.1" } }, + "pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, "pump": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", @@ -10950,6 +11259,15 @@ "string_decoder": "^1.3.0" } }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, "real-require": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", @@ -11282,6 +11600,15 @@ "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true }, + "simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "requires": { + "semver": "^7.5.3" + } + }, "slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -11594,6 +11921,12 @@ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", "dev": true }, + "touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true + }, "tr46": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz", @@ -11742,6 +12075,12 @@ "which-boxed-primitive": "^1.0.2" } }, + "undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, "undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", diff --git a/package.json b/package.json index 3790384..6f53476 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "main": "main.js", "scripts": { "start": "npm run build && node ./dist/src/main.cli.js", - "dev": "npm run ts ./src/main.rest.ts | pino-pretty --colorize --translateTime SYS:standard", + "dev": "nodemon", "build": "npm run clean && npm run compile", "lint": "eslint src/ --ext .ts", "lint:fix": "eslint src/ --ext .ts --fix", @@ -30,6 +30,7 @@ "eslint": "8.49.0", "eslint-config-htmlacademy": "9.1.1", "json-server": "0.17.3", + "nodemon": "3.1.7", "pino-pretty": "11.2.2", "rimraf": "5.0.1", "ts-node": "10.9.2", diff --git a/src/cli/commands/import.command.ts b/src/cli/commands/import.command.ts index ffffae8..aedca59 100644 --- a/src/cli/commands/import.command.ts +++ b/src/cli/commands/import.command.ts @@ -4,7 +4,6 @@ import { MongoDatabaseClient } from '../../shared/libs/database-client/mongo.dat import { TSVFileReader } from '../../shared/libs/file-reader/tsv.file-reader.js'; import { ConsoleLogger } from '../../shared/libs/logger/console.logger.js'; import { Logger } from '../../shared/libs/logger/logger.interface.js'; -import { DefaultFacilityService, FacilityModel, FacilityService } from '../../shared/modules/facility/index.js'; import { DefaultOfferService, OfferModel, OfferService } from '../../shared/modules/offer/index.js'; import { DefaultUserService, UserModel, UserService } from '../../shared/modules/user/index.js'; import { Offer } from '../../shared/types/index.js'; @@ -13,7 +12,6 @@ import { Command } from './command.interface.js'; export class ImportCommand implements Command { private userService: UserService; - private facilityService: FacilityService; private offerService: OfferService; private databaseClient: DatabaseClient; private logger: Logger; @@ -25,7 +23,6 @@ export class ImportCommand implements Command { this.logger = new ConsoleLogger(); this.offerService = new DefaultOfferService(this.logger, OfferModel); - this.facilityService = new DefaultFacilityService(this.logger, FacilityModel); this.userService = new DefaultUserService(this.logger, UserModel); this.databaseClient = new MongoDatabaseClient(this.logger); } @@ -36,19 +33,12 @@ export class ImportCommand implements Command { } private async saveOffer(offer: Offer) { - const facilities: string[] = []; const user = await this.userService.findOrCreate({ ...offer.user, password: DEFAULT_USER_PASSWORD }, this.salt); - for (const { name } of offer.facilities) { - const existFacility = await this.facilityService.findByFacilityNameOrCreate(name, { name }); - facilities.push(existFacility.id); - } - await this.offerService.create({ - facilities, userId: user.id, title: offer.title, description: offer.description, @@ -56,6 +46,7 @@ export class ImportCommand implements Command { images: offer.images, postDate: offer.postDate, price: offer.price, + facilities: offer.facilities, type: offer.type, city: offer.city, isPremium: offer.isPremium, diff --git a/src/main.rest.ts b/src/main.rest.ts index c7b1af8..7833374 100644 --- a/src/main.rest.ts +++ b/src/main.rest.ts @@ -4,7 +4,6 @@ import { Container } from 'inversify'; import { createRestApplicationContainer } from './rest/rest.container.js'; import { Component } from './shared/const.js'; import { RESTApplication } from './rest/rest.application.js'; -import { createFacilityContainer } from './shared/modules/facility/index.js'; import { createUserContainer } from './shared/modules/user/index.js'; import { createOfferContainer } from './shared/modules/offer/index.js'; @@ -12,7 +11,6 @@ async function bootstrap() { const container = Container.merge( createRestApplicationContainer(), createUserContainer(), - createFacilityContainer(), createOfferContainer(), ); diff --git a/src/shared/const.ts b/src/shared/const.ts index bc28c20..3bf2135 100644 --- a/src/shared/const.ts +++ b/src/shared/const.ts @@ -47,8 +47,6 @@ export const CITIES: City[] = [ export const CITIES_LIST = CITIES.map((city) => city.name); -export const FACILITIES = ['Breakfast', 'Air conditioning', 'Laptop friendly workspace', 'Baby seat', 'Washer', 'Towels', 'Fridge']; - export const Component = { RestApplication: Symbol.for('RestApplication'), Logger: Symbol.for('Logger'), @@ -56,8 +54,6 @@ export const Component = { DatabaseClient: Symbol.for('DatabaseClient'), UserService: Symbol.for('UserService'), UserModel: Symbol.for('UserModel'), - FacilityService: Symbol.for('FacilityService'), - FacilityModel: Symbol.for('FacilityModel'), OfferService: Symbol.for('OfferService'), OfferModel: Symbol.for('OfferModel'), } as const; diff --git a/src/shared/libs/file-reader/tsv.file-reader.ts b/src/shared/libs/file-reader/tsv.file-reader.ts index 64f5acc..e651861 100644 --- a/src/shared/libs/file-reader/tsv.file-reader.ts +++ b/src/shared/libs/file-reader/tsv.file-reader.ts @@ -25,10 +25,6 @@ export class TSVFileReader extends EventEmitter implements FileReader { return line.split(separator) ?? []; } - private parseFacilities(line: string): { name: string }[] { - return line.split(';').map((name) => ({ name })); - } - private parseUser(...params: string[]): User { const [name, email, avatar, password, isPro] = params; @@ -86,7 +82,7 @@ export class TSVFileReader extends EventEmitter implements FileReader { rooms: this.parseToNumber(rooms), guests: this.parseToNumber(guests), price: this.parseToNumber(price), - facilities: this.parseFacilities(facilities), + facilities: this.parseToArray(facilities), user: this.parseUser(name, email, avatar, password, isPro), location: this.parseLocation(lat, long), }; diff --git a/src/shared/modules/facility/default-facility.service.ts b/src/shared/modules/facility/default-facility.service.ts deleted file mode 100644 index ae1520b..0000000 --- a/src/shared/modules/facility/default-facility.service.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { inject, injectable } from 'inversify'; -import { DocumentType, types } from '@typegoose/typegoose'; -import { Logger } from '../../libs/logger/logger.interface.js'; -import { FacilityService } from './facility-service.interface.js'; -import { FacilityEntity } from './facility.entity.js'; -import { CreateFacilityDto } from './dto/create-facility.dto.js'; -import { Component } from '../../const.js'; - -@injectable() -export class DefaultFacilityService implements FacilityService { - constructor( - @inject(Component.Logger) private readonly logger: Logger, - @inject(Component.FacilityModel) private readonly facilityModel: types.ModelType - ) { } - - public async create(dto: CreateFacilityDto): Promise> { - const result = await this.facilityModel.create(dto); - this.logger.info(`New facility created: ${dto.name}`); - return result; - } - - public async findByFacilityId(facilityId: string): Promise | null> { - return this.facilityModel.findById(facilityId).exec(); - } - - public async findByFacilityName(facilityName: string): Promise | null> { - return this.facilityModel.findOne({ name: facilityName }).exec(); - } - - public async findByFacilityNameOrCreate(facilityName: string, dto: CreateFacilityDto): Promise> { - const existedFacility = await this.findByFacilityName(facilityName); - - if (existedFacility) { - return existedFacility; - } - - return this.create(dto); - } -} diff --git a/src/shared/modules/facility/dto/create-facility.dto.ts b/src/shared/modules/facility/dto/create-facility.dto.ts deleted file mode 100644 index 8c6ed42..0000000 --- a/src/shared/modules/facility/dto/create-facility.dto.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class CreateFacilityDto { - public name: string; -} diff --git a/src/shared/modules/facility/facility-service.interface.ts b/src/shared/modules/facility/facility-service.interface.ts deleted file mode 100644 index 8388583..0000000 --- a/src/shared/modules/facility/facility-service.interface.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { DocumentType } from '@typegoose/typegoose'; -import { CreateFacilityDto } from './dto/create-facility.dto.js'; -import { FacilityEntity } from './facility.entity.js'; - -export interface FacilityService { - create(dto: CreateFacilityDto): Promise>; - findByFacilityId(facilityId: string): Promise | null>; - findByFacilityName(facilityName: string): Promise | null>; - findByFacilityNameOrCreate(facilityName: string, dto: CreateFacilityDto): Promise>; -} diff --git a/src/shared/modules/facility/facility.container.ts b/src/shared/modules/facility/facility.container.ts deleted file mode 100644 index bc302ee..0000000 --- a/src/shared/modules/facility/facility.container.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Container } from 'inversify'; -import { Component } from '../../const.js'; -import { FacilityService } from './facility-service.interface.js'; -import { types } from '@typegoose/typegoose'; -import { FacilityEntity, FacilityModel } from './facility.entity.js'; -import { DefaultFacilityService } from './default-facility.service.js'; - - -export function createFacilityContainer() { - const facilityContainer = new Container(); - - facilityContainer.bind(Component.FacilityService).to(DefaultFacilityService); - facilityContainer.bind>(Component.FacilityModel).toConstantValue(FacilityModel); - - return facilityContainer; -} diff --git a/src/shared/modules/facility/facility.entity.ts b/src/shared/modules/facility/facility.entity.ts deleted file mode 100644 index 7203ed4..0000000 --- a/src/shared/modules/facility/facility.entity.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { defaultClasses, getModelForClass, modelOptions, prop } from '@typegoose/typegoose'; - -// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -export interface FacilityEntity extends defaultClasses.Base { } - -@modelOptions({ - schemaOptions: { - collection: 'facilities', - timestamps: true, - } -}) -// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -export class FacilityEntity extends defaultClasses.TimeStamps { - @prop({ required: true, trim: true }) - public name: string; -} - -export const FacilityModel = getModelForClass(FacilityEntity); diff --git a/src/shared/modules/facility/index.ts b/src/shared/modules/facility/index.ts deleted file mode 100644 index 17dfc82..0000000 --- a/src/shared/modules/facility/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { CreateFacilityDto } from './dto/create-facility.dto.js'; -export { FacilityService } from './facility-service.interface.js'; -export { FacilityEntity, FacilityModel } from './facility.entity.js'; -export { DefaultFacilityService } from './default-facility.service.js'; -export { createFacilityContainer } from './facility.container.js'; diff --git a/src/shared/modules/offer/offer.entity.ts b/src/shared/modules/offer/offer.entity.ts index 3f1fbaf..bd4b36e 100644 --- a/src/shared/modules/offer/offer.entity.ts +++ b/src/shared/modules/offer/offer.entity.ts @@ -1,6 +1,5 @@ import { defaultClasses, getModelForClass, modelOptions, prop, Ref, Severity } from '@typegoose/typegoose'; import { City, Location, OfferType } from '../../types/index.js'; -import { FacilityEntity } from '../facility/index.js'; import { UserEntity } from '../user/index.js'; // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging @@ -57,13 +56,8 @@ export class OfferEntity extends defaultClasses.TimeStamps { @prop({ required: true }) public price: number; - @prop({ - ref: FacilityEntity, - required: true, - default: [], - _id: false - }) - public facilities: Ref[]; + @prop({ required: true }) + public facilities: string[]; @prop({ ref: UserEntity, diff --git a/src/shared/types/facility.type.ts b/src/shared/types/facility.type.ts deleted file mode 100644 index 5309492..0000000 --- a/src/shared/types/facility.type.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type Facility = { - name: string; -} diff --git a/src/shared/types/index.ts b/src/shared/types/index.ts index 0254c65..3c950da 100644 --- a/src/shared/types/index.ts +++ b/src/shared/types/index.ts @@ -4,4 +4,3 @@ export { OfferType } from './offer-type.type.js'; export { User } from './user.type.js'; export { Offer } from './offer.type.js'; export { MockServerData } from './mock-server-data.type.js'; -export { Facility } from './facility.type.js'; diff --git a/src/shared/types/offer.type.ts b/src/shared/types/offer.type.ts index e0ea9c9..20acd02 100644 --- a/src/shared/types/offer.type.ts +++ b/src/shared/types/offer.type.ts @@ -2,7 +2,6 @@ import { City } from './city.type.js'; import { OfferType } from './offer-type.type.js'; import { User } from './user.type.js'; import { Location } from './location.type.js'; -import { Facility } from './facility.type.js'; export type Offer = { title: string; @@ -18,7 +17,7 @@ export type Offer = { rooms: number; guests: number; price: number; - facilities: Facility[]; + facilities: string[]; user: User; location: Location; }