From 9f50c3b2f1d046aa6f2a4d841e6d855b89911b49 Mon Sep 17 00:00:00 2001 From: sbriat Date: Mon, 3 Jul 2023 14:15:27 +0200 Subject: [PATCH] simplify broker --- package-lock.json | 337 +++++++++--------- src/app.constants.ts | 1 - src/app.module.ts | 8 +- src/modules/ad/ad.module.ts | 14 +- .../ad/infrastructure/message-publisher.ts | 16 - .../infrastructure/message-publisher.spec.ts | 36 -- src/modules/health/health.module.ts | 11 +- .../infrastructure/message-publisher.ts | 16 - .../tests/unit/message-publisher.spec.ts | 36 -- 9 files changed, 182 insertions(+), 293 deletions(-) delete mode 100644 src/modules/ad/infrastructure/message-publisher.ts delete mode 100644 src/modules/ad/tests/unit/infrastructure/message-publisher.spec.ts delete mode 100644 src/modules/health/infrastructure/message-publisher.ts delete mode 100644 src/modules/health/tests/unit/message-publisher.spec.ts diff --git a/package-lock.json b/package-lock.json index ae2781e..75f9533 100644 --- a/package-lock.json +++ b/package-lock.json @@ -342,7 +342,7 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.21.5", + "version": "7.22.5", "dev": true, "license": "MIT", "engines": { @@ -552,11 +552,11 @@ } }, "node_modules/@babel/plugin-syntax-jsx": { - "version": "7.21.4", + "version": "7.22.5", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" + "@babel/helper-plugin-utils": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -646,11 +646,11 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.21.4", + "version": "7.22.5", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" + "@babel/helper-plugin-utils": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -770,13 +770,13 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.0.3", + "version": "2.1.0", "dev": true, "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.5.2", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -812,7 +812,7 @@ "license": "MIT" }, "node_modules/@eslint/js": { - "version": "8.42.0", + "version": "8.44.0", "dev": true, "license": "MIT", "engines": { @@ -889,7 +889,7 @@ "license": "MIT" }, "node_modules/@grpc/grpc-js": { - "version": "1.8.15", + "version": "1.8.17", "license": "Apache-2.0", "dependencies": { "@grpc/proto-loader": "^0.7.0", @@ -1351,13 +1351,9 @@ } }, "node_modules/@jridgewell/source-map": { - "version": "0.3.3", + "version": "0.3.4", "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.0", - "@jridgewell/trace-mapping": "^0.3.9" - } + "license": "MIT" }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.15", @@ -1402,7 +1398,8 @@ }, "node_modules/@mobicoop/configuration-module": { "version": "1.2.0", - "license": "AGPL", + "resolved": "https://registry.npmjs.org/@mobicoop/configuration-module/-/configuration-module-1.2.0.tgz", + "integrity": "sha512-l0iDae7SgVVmjnCa2MBqAr3Er0yn4E7yiG8e7cs4XtNGUKrC1N0Ju56TEAraEYK9aZAZ36TCs06m1fep+rgwFA==", "dependencies": { "@golevelup/nestjs-rabbitmq": "^3.6.0", "@liaoliaots/nestjs-redis": "^9.0.5", @@ -1433,7 +1430,8 @@ }, "node_modules/@mobicoop/message-broker-module": { "version": "1.2.0", - "license": "AGPL", + "resolved": "https://registry.npmjs.org/@mobicoop/message-broker-module/-/message-broker-module-1.2.0.tgz", + "integrity": "sha512-RoSHHK1GyQ/QVDmm3JS/wBfh171oChvyEp6YWmJd12krFLrPVn9MoEvZdyT3I5J31oBiUabMPle5Kdpw+Nrmww==", "dependencies": { "@golevelup/nestjs-rabbitmq": "^3.6.0", "@types/amqplib": "^0.10.1", @@ -1525,11 +1523,11 @@ } }, "node_modules/@nestjs/common": { - "version": "9.4.2", + "version": "9.4.3", "license": "MIT", "dependencies": { "iterare": "1.2.1", - "tslib": "2.5.2", + "tslib": "2.5.3", "uid": "2.0.2" }, "funding": { @@ -1556,14 +1554,14 @@ } }, "node_modules/@nestjs/common/node_modules/tslib": { - "version": "2.5.2", + "version": "2.5.3", "license": "0BSD" }, "node_modules/@nestjs/config": { - "version": "2.3.2", + "version": "2.3.4", "license": "MIT", "dependencies": { - "dotenv": "16.0.3", + "dotenv": "16.1.4", "dotenv-expand": "10.0.0", "lodash": "4.17.21", "uuid": "9.0.0" @@ -1575,7 +1573,7 @@ } }, "node_modules/@nestjs/core": { - "version": "9.4.2", + "version": "9.4.3", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -1583,7 +1581,7 @@ "fast-safe-stringify": "2.1.1", "iterare": "1.2.1", "path-to-regexp": "3.2.0", - "tslib": "2.5.2", + "tslib": "2.5.3", "uid": "2.0.2" }, "funding": { @@ -1611,7 +1609,7 @@ } }, "node_modules/@nestjs/core/node_modules/tslib": { - "version": "2.5.2", + "version": "2.5.3", "license": "0BSD" }, "node_modules/@nestjs/cqrs": { @@ -1640,11 +1638,11 @@ } }, "node_modules/@nestjs/microservices": { - "version": "9.4.2", + "version": "9.4.3", "license": "MIT", "dependencies": { "iterare": "1.2.1", - "tslib": "2.5.2" + "tslib": "2.5.3" }, "funding": { "type": "opencollective", @@ -1696,18 +1694,18 @@ } }, "node_modules/@nestjs/microservices/node_modules/tslib": { - "version": "2.5.2", + "version": "2.5.3", "license": "0BSD" }, "node_modules/@nestjs/platform-express": { - "version": "9.4.2", + "version": "9.4.3", "license": "MIT", "dependencies": { "body-parser": "1.20.2", "cors": "2.8.5", "express": "4.18.2", "multer": "1.4.4-lts.1", - "tslib": "2.5.2" + "tslib": "2.5.3" }, "funding": { "type": "opencollective", @@ -1719,7 +1717,7 @@ } }, "node_modules/@nestjs/platform-express/node_modules/tslib": { - "version": "2.5.2", + "version": "2.5.3", "license": "0BSD" }, "node_modules/@nestjs/schematics": { @@ -1801,11 +1799,11 @@ } }, "node_modules/@nestjs/testing": { - "version": "9.4.2", + "version": "9.4.3", "dev": true, "license": "MIT", "dependencies": { - "tslib": "2.5.2" + "tslib": "2.5.3" }, "funding": { "type": "opencollective", @@ -1827,7 +1825,7 @@ } }, "node_modules/@nestjs/testing/node_modules/tslib": { - "version": "2.5.2", + "version": "2.5.3", "dev": true, "license": "0BSD" }, @@ -1880,11 +1878,11 @@ } }, "node_modules/@prisma/client": { - "version": "4.15.0", + "version": "4.16.2", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@prisma/engines-version": "4.15.0-28.8fbc245156db7124f997f4cecdd8d1219e360944" + "@prisma/engines-version": "4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81" }, "engines": { "node": ">=14.17" @@ -1899,13 +1897,13 @@ } }, "node_modules/@prisma/engines": { - "version": "4.15.0", + "version": "4.16.2", "devOptional": true, "hasInstallScript": true, "license": "Apache-2.0" }, "node_modules/@prisma/engines-version": { - "version": "4.15.0-28.8fbc245156db7124f997f4cecdd8d1219e360944", + "version": "4.16.1-1.4bc8b6e1b66cb932731fb1bdbbc550d1e010de81", "license": "Apache-2.0" }, "node_modules/@protobufjs/aspromise": { @@ -1966,7 +1964,7 @@ } }, "node_modules/@sinonjs/fake-timers": { - "version": "10.2.0", + "version": "10.3.0", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -2088,7 +2086,7 @@ "license": "MIT" }, "node_modules/@types/eslint": { - "version": "8.40.0", + "version": "8.40.2", "dev": true, "license": "MIT", "dependencies": { @@ -2140,6 +2138,11 @@ "@types/node": "*" } }, + "node_modules/@types/http-errors": { + "version": "2.0.1", + "dev": true, + "license": "MIT" + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.4", "dev": true, @@ -2223,10 +2226,11 @@ } }, "node_modules/@types/serve-static": { - "version": "1.15.1", + "version": "1.15.2", "dev": true, "license": "MIT", "dependencies": { + "@types/http-errors": "*", "@types/mime": "*", "@types/node": "*" } @@ -2276,14 +2280,14 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.59.9", + "version": "5.60.1", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.59.9", - "@typescript-eslint/type-utils": "5.59.9", - "@typescript-eslint/utils": "5.59.9", + "@typescript-eslint/scope-manager": "5.60.1", + "@typescript-eslint/type-utils": "5.60.1", + "@typescript-eslint/utils": "5.60.1", "debug": "^4.3.4", "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", @@ -2309,13 +2313,13 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.59.9", + "version": "5.60.1", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/scope-manager": "5.59.9", - "@typescript-eslint/types": "5.59.9", - "@typescript-eslint/typescript-estree": "5.59.9", + "@typescript-eslint/scope-manager": "5.60.1", + "@typescript-eslint/types": "5.60.1", + "@typescript-eslint/typescript-estree": "5.60.1", "debug": "^4.3.4" }, "engines": { @@ -2335,12 +2339,12 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.59.9", + "version": "5.60.1", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "5.59.9", - "@typescript-eslint/visitor-keys": "5.59.9" + "@typescript-eslint/types": "5.60.1", + "@typescript-eslint/visitor-keys": "5.60.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2351,12 +2355,12 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.59.9", + "version": "5.60.1", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "5.59.9", - "@typescript-eslint/utils": "5.59.9", + "@typescript-eslint/typescript-estree": "5.60.1", + "@typescript-eslint/utils": "5.60.1", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -2377,7 +2381,7 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.59.9", + "version": "5.60.1", "dev": true, "license": "MIT", "engines": { @@ -2389,12 +2393,12 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.59.9", + "version": "5.60.1", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "5.59.9", - "@typescript-eslint/visitor-keys": "5.59.9", + "@typescript-eslint/types": "5.60.1", + "@typescript-eslint/visitor-keys": "5.60.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -2415,16 +2419,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.59.9", + "version": "5.60.1", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.59.9", - "@typescript-eslint/types": "5.59.9", - "@typescript-eslint/typescript-estree": "5.59.9", + "@typescript-eslint/scope-manager": "5.60.1", + "@typescript-eslint/types": "5.60.1", + "@typescript-eslint/typescript-estree": "5.60.1", "eslint-scope": "^5.1.1", "semver": "^7.3.7" }, @@ -2440,11 +2444,11 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.59.9", + "version": "5.60.1", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "5.59.9", + "@typescript-eslint/types": "5.60.1", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -2608,7 +2612,7 @@ } }, "node_modules/acorn": { - "version": "8.8.2", + "version": "8.9.0", "dev": true, "license": "MIT", "bin": { @@ -3081,7 +3085,7 @@ } }, "node_modules/browserslist": { - "version": "4.21.7", + "version": "4.21.9", "dev": true, "funding": [ { @@ -3099,8 +3103,8 @@ ], "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001489", - "electron-to-chromium": "^1.4.411", + "caniuse-lite": "^1.0.30001503", + "electron-to-chromium": "^1.4.431", "node-releases": "^2.0.12", "update-browserslist-db": "^1.0.11" }, @@ -3207,7 +3211,7 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001495", + "version": "1.0.30001511", "dev": true, "funding": [ { @@ -3308,7 +3312,7 @@ } }, "node_modules/cjs-module-lexer": { - "version": "1.2.2", + "version": "1.2.3", "dev": true, "license": "MIT" }, @@ -3464,40 +3468,53 @@ "license": "MIT" }, "node_modules/concat-stream": { - "version": "1.6.2", + "version": "2.0.0", "engines": [ - "node >= 0.8" + "node >= 6.0" ], "license": "MIT", "dependencies": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", - "readable-stream": "^2.2.2", + "readable-stream": "^3.0.2", "typedarray": "^0.0.6" } }, - "node_modules/concat-stream/node_modules/isarray": { - "version": "1.0.0", - "license": "MIT" - }, "node_modules/concat-stream/node_modules/readable-stream": { - "version": "2.3.8", + "version": "3.6.2", "license": "MIT", "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" } }, + "node_modules/concat-stream/node_modules/safe-buffer": { + "version": "5.2.1", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/concat-stream/node_modules/string_decoder": { - "version": "1.1.1", + "version": "1.3.0", "license": "MIT", "dependencies": { - "safe-buffer": "~5.1.0" + "safe-buffer": "~5.2.0" } }, "node_modules/consola": { @@ -3738,10 +3755,13 @@ } }, "node_modules/dotenv": { - "version": "16.0.3", + "version": "16.1.4", "license": "BSD-2-Clause", "engines": { "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" } }, "node_modules/dotenv-cli": { @@ -3770,7 +3790,7 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.4.425", + "version": "1.4.447", "dev": true, "license": "ISC" }, @@ -3805,7 +3825,7 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.14.1", + "version": "5.15.0", "dev": true, "license": "MIT", "dependencies": { @@ -3825,7 +3845,7 @@ } }, "node_modules/es-module-lexer": { - "version": "1.2.1", + "version": "1.3.0", "dev": true, "license": "MIT" }, @@ -3852,14 +3872,14 @@ } }, "node_modules/eslint": { - "version": "8.42.0", + "version": "8.44.0", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.42.0", + "@eslint/eslintrc": "^2.1.0", + "@eslint/js": "8.44.0", "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -3871,7 +3891,7 @@ "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.2.0", "eslint-visitor-keys": "^3.4.1", - "espree": "^9.5.2", + "espree": "^9.6.0", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -3891,7 +3911,7 @@ "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" @@ -4015,11 +4035,11 @@ "license": "MIT" }, "node_modules/espree": { - "version": "9.5.2", + "version": "9.6.0", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.4.1" }, @@ -4291,7 +4311,7 @@ "license": "Apache-2.0" }, "node_modules/fast-glob": { - "version": "3.2.12", + "version": "3.3.0", "dev": true, "license": "MIT", "dependencies": { @@ -4589,56 +4609,6 @@ "shp2geobuf": "bin/shp2geobuf" } }, - "node_modules/geobuf/node_modules/concat-stream": { - "version": "2.0.0", - "engines": [ - "node >= 6.0" - ], - "license": "MIT", - "dependencies": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.0.2", - "typedarray": "^0.0.6" - } - }, - "node_modules/geobuf/node_modules/readable-stream": { - "version": "3.6.2", - "license": "MIT", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/geobuf/node_modules/safe-buffer": { - "version": "5.2.1", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/geobuf/node_modules/string_decoder": { - "version": "1.3.0", - "license": "MIT", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "license": "ISC", @@ -5819,7 +5789,7 @@ } }, "node_modules/libphonenumber-js": { - "version": "1.10.34", + "version": "1.10.37", "license": "MIT" }, "node_modules/lines-and-columns": { @@ -6104,6 +6074,43 @@ "node": ">= 6.0.0" } }, + "node_modules/multer/node_modules/concat-stream": { + "version": "1.6.2", + "engines": [ + "node >= 0.8" + ], + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/multer/node_modules/isarray": { + "version": "1.0.0", + "license": "MIT" + }, + "node_modules/multer/node_modules/readable-stream": { + "version": "2.3.8", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/multer/node_modules/string_decoder": { + "version": "1.1.1", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/mute-stream": { "version": "0.0.8", "dev": true, @@ -6168,7 +6175,7 @@ } }, "node_modules/node-fetch": { - "version": "2.6.11", + "version": "2.6.12", "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" @@ -6422,11 +6429,11 @@ "license": "MIT" }, "node_modules/path-scurry": { - "version": "1.9.2", + "version": "1.10.0", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "lru-cache": "^9.1.1", + "lru-cache": "^9.1.1 || ^10.0.0", "minipass": "^5.0.0 || ^6.0.2" }, "engines": { @@ -6437,7 +6444,7 @@ } }, "node_modules/path-scurry/node_modules/lru-cache": { - "version": "9.1.2", + "version": "10.0.0", "dev": true, "license": "ISC", "engines": { @@ -6500,7 +6507,7 @@ } }, "node_modules/pirates": { - "version": "4.0.5", + "version": "4.0.6", "dev": true, "license": "MIT", "engines": { @@ -6632,12 +6639,12 @@ } }, "node_modules/prisma": { - "version": "4.15.0", + "version": "4.16.2", "devOptional": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@prisma/engines": "4.15.0" + "@prisma/engines": "4.16.2" }, "bin": { "prisma": "build/index.js", @@ -6668,7 +6675,7 @@ } }, "node_modules/protobufjs": { - "version": "7.2.3", + "version": "7.2.4", "hasInstallScript": true, "license": "BSD-3-Clause", "dependencies": { @@ -7061,7 +7068,7 @@ "license": "MIT" }, "node_modules/schema-utils": { - "version": "3.2.0", + "version": "3.3.0", "dev": true, "license": "MIT", "dependencies": { @@ -7502,7 +7509,7 @@ } }, "node_modules/terser": { - "version": "5.17.7", + "version": "5.18.2", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -7714,7 +7721,7 @@ } }, "node_modules/ts-loader": { - "version": "9.4.3", + "version": "9.4.4", "dev": true, "license": "MIT", "dependencies": { @@ -8048,7 +8055,7 @@ "license": "BSD-2-Clause" }, "node_modules/webpack": { - "version": "5.86.0", + "version": "5.88.1", "dev": true, "license": "MIT", "peer": true, @@ -8062,7 +8069,7 @@ "acorn-import-assertions": "^1.9.0", "browserslist": "^4.14.5", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.14.1", + "enhanced-resolve": "^5.15.0", "es-module-lexer": "^1.2.1", "eslint-scope": "5.1.1", "events": "^3.2.0", @@ -8072,7 +8079,7 @@ "loader-runner": "^4.2.0", "mime-types": "^2.1.27", "neo-async": "^2.6.2", - "schema-utils": "^3.1.2", + "schema-utils": "^3.2.0", "tapable": "^2.1.1", "terser-webpack-plugin": "^5.3.7", "watchpack": "^2.4.0", diff --git a/src/app.constants.ts b/src/app.constants.ts index ff96e07..61203bb 100644 --- a/src/app.constants.ts +++ b/src/app.constants.ts @@ -1,2 +1 @@ -export const MESSAGE_BROKER_PUBLISHER = Symbol(); export const MESSAGE_PUBLISHER = Symbol(); diff --git a/src/app.module.ts b/src/app.module.ts index a2b6bc2..29d04e8 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,10 +1,6 @@ import { Module } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { AdModule } from './modules/ad/ad.module'; -import { - MessageBrokerModule, - MessageBrokerModuleOptions, -} from '@mobicoop/message-broker-module'; import { ConfigurationModule, ConfigurationModuleOptions, @@ -12,6 +8,10 @@ import { import { EventEmitterModule } from '@nestjs/event-emitter'; import { RequestContextModule } from 'nestjs-request-context'; import { HealthModule } from '@modules/health/health.module'; +import { + MessageBrokerModule, + MessageBrokerModuleOptions, +} from '@mobicoop/message-broker-module'; @Module({ imports: [ diff --git a/src/modules/ad/ad.module.ts b/src/modules/ad/ad.module.ts index 7360608..466e061 100644 --- a/src/modules/ad/ad.module.ts +++ b/src/modules/ad/ad.module.ts @@ -7,14 +7,9 @@ import { TIMEZONE_FINDER, TIME_CONVERTER, } from './ad.di-tokens'; -import { - MESSAGE_BROKER_PUBLISHER, - MESSAGE_PUBLISHER, -} from '@src/app.constants'; -import { MessageBrokerPublisher } from '@mobicoop/message-broker-module'; +import { MESSAGE_PUBLISHER } from '@src/app.constants'; import { AdRepository } from './infrastructure/ad.repository'; import { DefaultParamsProvider } from './infrastructure/default-params-provider'; -import { MessagePublisher } from './infrastructure/message-publisher'; import { AdMapper } from './ad.mapper'; import { CreateAdService } from './core/application/commands/create-ad/create-ad.service'; import { TimezoneFinder } from './infrastructure/timezone-finder'; @@ -24,6 +19,7 @@ import { FindAdByIdQueryHandler } from './core/application/queries/find-ad-by-id import { PublishMessageWhenAdIsCreatedDomainEventHandler } from './core/application/event-handlers/publish-message-when-ad-is-created.domain-event-handler'; import { PublishLogMessageWhenAdIsCreatedDomainEventHandler } from './core/application/event-handlers/publish-log-message-when-ad-is-created.domain-event-handler'; import { PrismaService } from './infrastructure/prisma.service'; +import { MessageBrokerPublisher } from '@mobicoop/message-broker-module'; const grpcControllers = [CreateAdGrpcController, FindAdByIdGrpcController]; @@ -46,13 +42,9 @@ const repositories: Provider[] = [ ]; const messageBrokers: Provider[] = [ - { - provide: MESSAGE_BROKER_PUBLISHER, - useClass: MessageBrokerPublisher, - }, { provide: MESSAGE_PUBLISHER, - useClass: MessagePublisher, + useClass: MessageBrokerPublisher, }, ]; diff --git a/src/modules/ad/infrastructure/message-publisher.ts b/src/modules/ad/infrastructure/message-publisher.ts deleted file mode 100644 index c0b5bfd..0000000 --- a/src/modules/ad/infrastructure/message-publisher.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Inject, Injectable } from '@nestjs/common'; -import { MessageBrokerPublisher } from '@mobicoop/message-broker-module'; -import { MESSAGE_BROKER_PUBLISHER } from '@src/app.constants'; -import { MessagePublisherPort } from '@mobicoop/ddd-library'; - -@Injectable() -export class MessagePublisher implements MessagePublisherPort { - constructor( - @Inject(MESSAGE_BROKER_PUBLISHER) - private readonly messageBrokerPublisher: MessageBrokerPublisher, - ) {} - - publish = (routingKey: string, message: string): void => { - this.messageBrokerPublisher.publish(routingKey, message); - }; -} diff --git a/src/modules/ad/tests/unit/infrastructure/message-publisher.spec.ts b/src/modules/ad/tests/unit/infrastructure/message-publisher.spec.ts deleted file mode 100644 index 54dab1f..0000000 --- a/src/modules/ad/tests/unit/infrastructure/message-publisher.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { MessagePublisher } from '@modules/ad/infrastructure/message-publisher'; -import { Test, TestingModule } from '@nestjs/testing'; -import { MESSAGE_BROKER_PUBLISHER } from '@src/app.constants'; - -const mockMessageBrokerPublisher = { - publish: jest.fn().mockImplementation(), -}; - -describe('Messager', () => { - let messagePublisher: MessagePublisher; - - beforeAll(async () => { - const module: TestingModule = await Test.createTestingModule({ - imports: [], - providers: [ - MessagePublisher, - { - provide: MESSAGE_BROKER_PUBLISHER, - useValue: mockMessageBrokerPublisher, - }, - ], - }).compile(); - - messagePublisher = module.get(MessagePublisher); - }); - - it('should be defined', () => { - expect(messagePublisher).toBeDefined(); - }); - - it('should publish a message', async () => { - jest.spyOn(mockMessageBrokerPublisher, 'publish'); - messagePublisher.publish('health.info', 'my-test'); - expect(mockMessageBrokerPublisher.publish).toHaveBeenCalledTimes(1); - }); -}); diff --git a/src/modules/health/health.module.ts b/src/modules/health/health.module.ts index 5e30741..fe1565a 100644 --- a/src/modules/health/health.module.ts +++ b/src/modules/health/health.module.ts @@ -1,14 +1,13 @@ import { Module, Provider } from '@nestjs/common'; import { HealthHttpController } from './interface/http-controllers/health.http.controller'; import { TerminusModule } from '@nestjs/terminus'; -import { MESSAGE_BROKER_PUBLISHER, MESSAGE_PUBLISHER } from 'src/app.constants'; -import { MessageBrokerPublisher } from '@mobicoop/message-broker-module'; -import { MessagePublisher } from './infrastructure/message-publisher'; +import { MESSAGE_PUBLISHER } from 'src/app.constants'; import { RepositoriesHealthIndicatorUseCase } from './core/application/usecases/repositories.health-indicator.usecase'; import { AdRepository } from '../ad/infrastructure/ad.repository'; import { AD_REPOSITORY } from './health.di-tokens'; import { HealthGrpcController } from './interface/grpc-controllers/health.grpc.controller'; import { AdModule } from '@modules/ad/ad.module'; +import { MessageBrokerPublisher } from '@mobicoop/message-broker-module'; const grpcControllers = [HealthGrpcController]; @@ -24,13 +23,9 @@ const repositories: Provider[] = [ ]; const messageBrokers: Provider[] = [ - { - provide: MESSAGE_BROKER_PUBLISHER, - useClass: MessageBrokerPublisher, - }, { provide: MESSAGE_PUBLISHER, - useClass: MessagePublisher, + useClass: MessageBrokerPublisher, }, ]; diff --git a/src/modules/health/infrastructure/message-publisher.ts b/src/modules/health/infrastructure/message-publisher.ts deleted file mode 100644 index 0177bc3..0000000 --- a/src/modules/health/infrastructure/message-publisher.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Inject, Injectable } from '@nestjs/common'; -import { MESSAGE_BROKER_PUBLISHER } from '../../../app.constants'; -import { MessageBrokerPublisher } from '@mobicoop/message-broker-module'; -import { MessagePublisherPort } from '@mobicoop/ddd-library'; - -@Injectable() -export class MessagePublisher implements MessagePublisherPort { - constructor( - @Inject(MESSAGE_BROKER_PUBLISHER) - private readonly messageBrokerPublisher: MessageBrokerPublisher, - ) {} - - publish = (routingKey: string, message: string): void => { - this.messageBrokerPublisher.publish(routingKey, message); - }; -} diff --git a/src/modules/health/tests/unit/message-publisher.spec.ts b/src/modules/health/tests/unit/message-publisher.spec.ts deleted file mode 100644 index 7b3e9a9..0000000 --- a/src/modules/health/tests/unit/message-publisher.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { MessagePublisher } from '@modules/health/infrastructure/message-publisher'; -import { Test, TestingModule } from '@nestjs/testing'; -import { MESSAGE_BROKER_PUBLISHER } from '@src/app.constants'; - -const mockMessageBrokerPublisher = { - publish: jest.fn().mockImplementation(), -}; - -describe('Messager', () => { - let messagePublisher: MessagePublisher; - - beforeAll(async () => { - const module: TestingModule = await Test.createTestingModule({ - imports: [], - providers: [ - MessagePublisher, - { - provide: MESSAGE_BROKER_PUBLISHER, - useValue: mockMessageBrokerPublisher, - }, - ], - }).compile(); - - messagePublisher = module.get(MessagePublisher); - }); - - it('should be defined', () => { - expect(messagePublisher).toBeDefined(); - }); - - it('should publish a message', async () => { - jest.spyOn(mockMessageBrokerPublisher, 'publish'); - messagePublisher.publish('health.info', 'my-test'); - expect(mockMessageBrokerPublisher.publish).toHaveBeenCalledTimes(1); - }); -});