From 451d14b316a4895bb67c207e07da69b8934a4920 Mon Sep 17 00:00:00 2001 From: Emanuele De Cupis Date: Fri, 8 May 2020 10:02:49 +0200 Subject: [PATCH 1/3] update io-functions-commons --- package.json | 4 +- yarn.lock | 139 +++++++++++++++++++++++---------------------------- 2 files changed, 65 insertions(+), 78 deletions(-) diff --git a/package.json b/package.json index d66259e0..ea753caa 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "prestart": "npm run build && func extensions install", "start:host": "func start", "start": "npm-run-all --parallel start:host watch", - "pretest": "yarn generate:definitions", + "_pretest": "yarn generate:definitions", "test": "dotenv -e env.example -- jest", "pretest:coverage": "yarn generate:definitions", "test:coverage": "dotenv -e env.example -- jest --coverage", @@ -54,7 +54,7 @@ "durable-functions": "^1.2.4", "express": "^4.15.3", "fp-ts": "1.17.0", - "io-functions-commons": "^4.0.1", + "io-functions-commons": "^9.0.0", "io-functions-express": "^0.1.0", "io-ts": "1.8.5", "italia-ts-commons": "^5.1.11", diff --git a/yarn.lock b/yarn.lock index 4d3c3293..e5bf6727 100644 --- a/yarn.lock +++ b/yarn.lock @@ -695,6 +695,14 @@ resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d" integrity sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw== +"@types/node-fetch@^2.5.6": + version "2.5.7" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.7.tgz#20a2afffa882ab04d44ca786449a276f9f6bbf3c" + integrity sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw== + dependencies: + "@types/node" "*" + form-data "^3.0.0" + "@types/node@*": version "12.0.8" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.0.8.tgz#551466be11b2adc3f3d47156758f610bd9f6b1d8" @@ -870,6 +878,14 @@ agent-base@4, agent-base@^4.3.0: dependencies: es6-promisify "^5.0.0" +"agentkeepalive@https://github.com/pagopa/agentkeepalive#v4.1.1": + version "4.1.0" + resolved "https://github.com/pagopa/agentkeepalive#91309bcab216dccbd08631e227a974afbfe807fb" + dependencies: + debug "^4.1.0" + depd "^1.1.2" + humanize-ms "^1.2.1" + ajv@^6.5.5: version "6.10.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.0.tgz#90d0d54439da587cd7e843bfb7045f50bd22bdf1" @@ -964,15 +980,15 @@ append-transform@^0.4.0: dependencies: default-require-extensions "^1.0.0" -applicationinsights@^1.0.3: - version "1.7.2" - resolved "https://registry.yarnpkg.com/applicationinsights/-/applicationinsights-1.7.2.tgz#c41f2485cc52589828783ed54f170c142e176c53" - integrity sha512-AtofsH08vrGTMDwXVK6+1wITd8ou9gksFV95JLZo7lVL0wX7/W1qeAZ13DK/6P3VJVsSMJ0sjdVNn98C4XxGvw== +applicationinsights@^1.7.3, applicationinsights@^1.7.4: + version "1.7.5" + resolved "https://registry.yarnpkg.com/applicationinsights/-/applicationinsights-1.7.5.tgz#423d9b58cd20117d724b86811935de9ddab8b852" + integrity sha512-sl3rNhVnQOG4ecJNKh7dlAZOc/DLfZTRs1F6PO3nb969AsnVg7C4xWRoybI9+mbtqyPR4NA2JbG4bHJOGP3j+A== dependencies: cls-hooked "^4.2.2" continuation-local-storage "^3.2.1" diagnostic-channel "0.2.0" - diagnostic-channel-publishers "^0.3.3" + diagnostic-channel-publishers "^0.3.4" aproba@^1.0.3: version "1.2.0" @@ -2052,7 +2068,7 @@ commander@~2.9.0: dependencies: graceful-readlink ">= 1.0.0" -component-emitter@^1.2.0, component-emitter@^1.2.1: +component-emitter@^1.2.1: version "1.3.0" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== @@ -2126,11 +2142,6 @@ cookie@0.4.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== -cookiejar@^2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c" - integrity sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA== - copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" @@ -2432,7 +2443,7 @@ depd@2.0.0: resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== -depd@~1.1.2: +depd@^1.1.2, depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= @@ -2489,10 +2500,10 @@ detect-repo-changelog@1.0.1: lodash.find "^4.6.0" pify "^2.3.0" -diagnostic-channel-publishers@^0.3.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.3.3.tgz#376b7798f4fa90f37eb4f94d2caca611b0e9c330" - integrity sha512-qIocRYU5TrGUkBlDDxaziAK1+squ8Yf2Ls4HldL3xxb/jzmWO2Enux7CvevNKYmF2kDXZ9HiRqwjPsjk8L+i2Q== +diagnostic-channel-publishers@^0.3.4: + version "0.3.4" + resolved "https://registry.yarnpkg.com/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.3.4.tgz#d862a5156090093e0d12f6e59e8d3b119efa9563" + integrity sha512-SZ1zMfFiEabf4Qx0Og9V1gMsRoqz3O+5ENkVcNOfI+SMJ3QhQsdEoKX99r0zvreagXot2parPxmrwwUM/ja8ug== diagnostic-channel@0.2.0: version "0.2.0" @@ -3220,7 +3231,7 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= -form-data@3.0.0: +form-data@3.0.0, form-data@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.0.tgz#31b7e39c85f1355b7139ee0c647cf0de7f83c682" integrity sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg== @@ -3229,15 +3240,6 @@ form-data@3.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" -form-data@^2.3.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.5.1.tgz#f2cbec57b5e59e23716e128fe44d4e5dd23895f4" - integrity sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.6" - mime-types "^2.1.12" - form-data@^2.3.2: version "2.4.0" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.4.0.tgz#4902b831b051e0db5612a35e1a098376f7b13ad8" @@ -3256,17 +3258,12 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" -formidable@^1.2.0: - version "1.2.2" - resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.2.2.tgz#bf69aea2972982675f00865342b982986f6b8dd9" - integrity sha512-V8gLm+41I/8kguQ4/o1D3RIHRmhYFG4pnNyonvua+40rqcEmT4+V71yaZ3B457xbbgCsCfjSPi65u/W6vK1U5Q== - forwarded@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ= -fp-ts@1.12.0, fp-ts@1.17.0, fp-ts@^1.0.0: +fp-ts@1.12.0, fp-ts@1.17.0, fp-ts@1.17.4, fp-ts@^1.0.0: version "1.17.0" resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-1.17.0.tgz#289127353ddbb4622ada1920d4ad6643182c1f1f" integrity sha512-nBq25aCAMbCwVLobUUuM/MZihPKyjn0bCVBf6xMAGriHlf8W8Ze9UhyfLnbmfp0ekFTxMuTfLXrCzpJ34px7PQ== @@ -3822,6 +3819,13 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== +humanize-ms@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" + integrity sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0= + dependencies: + ms "^2.0.0" + hyperlinker@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/hyperlinker/-/hyperlinker-1.0.0.tgz#23dc9e38a206b208ee49bc2d6c8ef47027df0c0e" @@ -3965,25 +3969,29 @@ invert-kv@^2.0.0: resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA== -io-functions-commons@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/io-functions-commons/-/io-functions-commons-4.0.1.tgz#5f81d4816301ba72ac7163b86d09c092f890e397" - integrity sha512-IA/5O6EPWakWKhPhH1NDowhf70En7gU7VUPqe1BZAfI9tWB0JmzkKFGrGLgN7uNSE/FNgfild0uPRcVKnmYrtA== +io-functions-commons@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/io-functions-commons/-/io-functions-commons-9.0.0.tgz#34c8ca58a590fba87c972d6b738acd93c16f1cb6" + integrity sha512-I+7qASSdt85PtyQVFH7vmlkvfGf7oZ9dVwo6Ty2evjBlFk3VPbfFUQWsT+8ClJF3RieMV1vnyCy850s8xYzYTw== dependencies: - applicationinsights "^1.0.3" + "@types/node-fetch" "^2.5.6" + applicationinsights "^1.7.3" azure-storage "^2.10.3" cidr-matcher "^2.1.0" documentdb "^1.15.3" + fp-ts "1.17.4" helmet "^3.13.0" helmet-csp "^2.5.1" io-functions-express "^0.1.1" + io-ts "1.8.5" + italia-ts-commons "^7.0.1" + node-fetch "^2.6.0" nodemailer "^4.6.7" referrer-policy "^1.1.0" rehype-stringify "^3.0.0" remark-parse "^5.0.0" remark-rehype "^3.0.0" request-ip "^2.1.3" - superagent "^3.8.3" ulid "^2.3.0" unified "^7.1.0" winston "^3.1.0" @@ -4546,6 +4554,19 @@ italia-ts-commons@^5.0.1, italia-ts-commons@^5.1.11: json-set-map "^1.0.2" validator "^10.1.0" +italia-ts-commons@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/italia-ts-commons/-/italia-ts-commons-7.0.1.tgz#7068643b09f069f4c96627e609d5dc578a64a04a" + integrity sha512-IIZYim8LydSA3nbeCxbR23marXhx3Z/FLUh7cV6XxNrB5OpKeVMmQhXV42oErP+g/vsrCQ/LRSrLX8cpi1Nghg== + dependencies: + agentkeepalive "https://github.com/pagopa/agentkeepalive#v4.1.1" + applicationinsights "^1.7.4" + fp-ts "1.17.4" + io-ts "1.8.5" + json-set-map "^1.0.2" + node-fetch "^2.6.0" + validator "^10.1.0" + italia-tslint-rules@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/italia-tslint-rules/-/italia-tslint-rules-1.1.3.tgz#efac0c9638d14cef6cc907be74f0799b8bab0976" @@ -5919,7 +5940,7 @@ merge@^1.2.0: resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.1.tgz#38bebf80c3220a8a487b6fcfb3941bb11720c145" integrity sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ== -methods@^1.1.1, methods@~1.1.2: +methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= @@ -5994,7 +6015,7 @@ mime-types@^2.1.12, mime-types@~2.1.19, mime-types@~2.1.24: dependencies: mime-db "1.40.0" -mime@1.6.0, mime@^1.4.1: +mime@1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== @@ -6119,7 +6140,7 @@ ms@2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@^2.1.1: +ms@^2.0.0, ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== @@ -6213,7 +6234,7 @@ node-fetch@^1.7.1: encoding "^0.1.11" is-stream "^1.0.1" -node-fetch@^2.1.1, node-fetch@^2.2.0, node-fetch@^2.3.0: +node-fetch@^2.1.1, node-fetch@^2.2.0, node-fetch@^2.3.0, node-fetch@^2.6.0: version "2.6.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== @@ -7125,11 +7146,6 @@ qs@6.7.0: resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== -qs@^6.5.1: - version "6.9.1" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.1.tgz#20082c65cb78223635ab1a9eaca8875a29bf8ec9" - integrity sha512-Cxm7/SS/y/Z3MHWSxXb8lIFqgqBowP5JMlTUFyJN88y0SGQhVmZnqFK/PeuMX9LzUyWsqqhNxIyg0jlzq946yA== - qs@~6.5.2: version "6.5.2" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" @@ -7228,19 +7244,6 @@ readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^2.3.5: - version "2.3.7" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" - integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== - 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" - readable-stream@^3.1.1: version "3.4.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.4.0.tgz#a51c26754658e0a3c21dbf59163bd45ba6f447fc" @@ -8226,22 +8229,6 @@ subdirs@^1.0.1: dependencies: es6-promise "^3.0.2" -superagent@^3.8.3: - version "3.8.3" - resolved "https://registry.yarnpkg.com/superagent/-/superagent-3.8.3.tgz#460ea0dbdb7d5b11bc4f78deba565f86a178e128" - integrity sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA== - dependencies: - component-emitter "^1.2.0" - cookiejar "^2.1.0" - debug "^3.1.0" - extend "^3.0.0" - form-data "^2.3.1" - formidable "^1.2.0" - methods "^1.1.1" - mime "^1.4.1" - qs "^6.5.1" - readable-stream "^2.3.5" - supports-color@7.1.0, supports-color@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1" From 498ffcda824cf66fc34b106524162c1fde423e56 Mon Sep 17 00:00:00 2001 From: Emanuele De Cupis Date: Fri, 8 May 2020 10:03:48 +0200 Subject: [PATCH 2/3] removed custom telemetry implementation --- CreateService/__tests__/handler.test.ts | 15 +++-------- CreateService/handler.ts | 5 +--- CreateService/index.ts | 14 +--------- GetService/__tests__/handler.test.ts | 15 +++-------- GetService/handler.ts | 9 ++----- GetService/index.ts | 14 +--------- UpdateService/__tests__/handler.test.ts | 35 +++++-------------------- UpdateService/handler.ts | 5 +--- 8 files changed, 19 insertions(+), 93 deletions(-) diff --git a/CreateService/__tests__/handler.test.ts b/CreateService/__tests__/handler.test.ts index e276612f..37314eb6 100644 --- a/CreateService/__tests__/handler.test.ts +++ b/CreateService/__tests__/handler.test.ts @@ -36,10 +36,7 @@ describe("CreateServiceHandler", () => { }) }; - const createServiceHandler = CreateServiceHandler( - undefined as any, - mockServiceModel as any - ); + const createServiceHandler = CreateServiceHandler(mockServiceModel as any); const response = await createServiceHandler( undefined as any, // Not used @@ -64,10 +61,7 @@ describe("CreateServiceHandler", () => { }) }; - const createServiceHandler = CreateServiceHandler( - undefined as any, - mockServiceModel as any - ); + const createServiceHandler = CreateServiceHandler(mockServiceModel as any); const response = await createServiceHandler( undefined as any, // Not used @@ -99,10 +93,7 @@ describe("CreateServiceHandler", () => { log: jest.fn() }; - const createServiceHandler = CreateServiceHandler( - undefined as any, - mockServiceModel as any - ); + const createServiceHandler = CreateServiceHandler(mockServiceModel as any); await createServiceHandler( contextMock as any, // Not used diff --git a/CreateService/handler.ts b/CreateService/handler.ts index e16c35d4..2543b66a 100644 --- a/CreateService/handler.ts +++ b/CreateService/handler.ts @@ -14,7 +14,6 @@ import { import { Service as ApiService } from "io-functions-commons/dist/generated/definitions/Service"; import { ServiceModel } from "io-functions-commons/dist/src/models/service"; -import { CustomTelemetryClientFactory } from "io-functions-commons/dist/src/utils/application_insights"; import { AzureApiAuthMiddleware, IAzureApiAuthorization, @@ -48,7 +47,6 @@ type ICreateServiceHandler = ( >; export function CreateServiceHandler( - _GCTC: CustomTelemetryClientFactory, serviceModel: ServiceModel ): ICreateServiceHandler { return async (context, _, servicePayload) => { @@ -88,10 +86,9 @@ export function CreateServiceHandler( * Wraps a CreateService handler inside an Express request handler. */ export function CreateService( - getCustomTelemetryClient: CustomTelemetryClientFactory, serviceModel: ServiceModel ): express.RequestHandler { - const handler = CreateServiceHandler(getCustomTelemetryClient, serviceModel); + const handler = CreateServiceHandler(serviceModel); const middlewaresWrap = withRequestMiddlewares( // Extract Azure Functions bindings diff --git a/CreateService/index.ts b/CreateService/index.ts index 61fdec00..a3a9e74d 100755 --- a/CreateService/index.ts +++ b/CreateService/index.ts @@ -10,10 +10,6 @@ import { ServiceModel } from "io-functions-commons/dist/src/models/service"; -import { - TelemetryClient, - wrapCustomTelemetryClient -} from "io-functions-commons/dist/src/utils/application_insights"; import * as documentDbUtils from "io-functions-commons/dist/src/utils/documentdb"; import { getRequiredStringEnv } from "io-functions-commons/dist/src/utils/env"; import { secureExpressApp } from "io-functions-commons/dist/src/utils/express"; @@ -27,11 +23,6 @@ import { CreateService } from "./handler"; // Whether we're in a production environment const isProduction = process.env.NODE_ENV === "production"; -const getCustomTelemetryClient = wrapCustomTelemetryClient( - isProduction, - new TelemetryClient() -); - const cosmosDbUri = getRequiredStringEnv("COSMOSDB_URI"); const cosmosDbKey = getRequiredStringEnv("COSMOSDB_KEY"); const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME"); @@ -60,10 +51,7 @@ const app = express(); secureExpressApp(app); // Add express route -app.post( - "/adm/services", - CreateService(getCustomTelemetryClient, serviceModel) -); +app.post("/adm/services", CreateService(serviceModel)); const azureFunctionHandler = createAzureFunctionHandler(app); diff --git a/GetService/__tests__/handler.test.ts b/GetService/__tests__/handler.test.ts index 9b9a0423..718fc5c1 100644 --- a/GetService/__tests__/handler.test.ts +++ b/GetService/__tests__/handler.test.ts @@ -18,10 +18,7 @@ describe("GetServiceHandler", () => { }) }; - const getServiceHandler = GetServiceHandler( - undefined as any, - mockServiceModel as any - ); + const getServiceHandler = GetServiceHandler(mockServiceModel as any); const response = await getServiceHandler( undefined as any, // Not used undefined as any, // Not used @@ -42,10 +39,7 @@ describe("GetServiceHandler", () => { }) }; - const getServiceHandler = GetServiceHandler( - undefined as any, - mockServiceModel as any - ); + const getServiceHandler = GetServiceHandler(mockServiceModel as any); const response = await getServiceHandler( undefined as any, // Not used undefined as any, // Not used @@ -66,10 +60,7 @@ describe("GetServiceHandler", () => { }) }; - const getServiceHandler = GetServiceHandler( - undefined as any, - mockServiceModel as any - ); + const getServiceHandler = GetServiceHandler(mockServiceModel as any); const response = await getServiceHandler( undefined as any, // Not used undefined as any, // Not used diff --git a/GetService/handler.ts b/GetService/handler.ts index 401d4038..40463ef3 100644 --- a/GetService/handler.ts +++ b/GetService/handler.ts @@ -15,7 +15,6 @@ import { import { Service as ApiService } from "io-functions-commons/dist/generated/definitions/Service"; import { ServiceId } from "io-functions-commons/dist/generated/definitions/ServiceId"; import { ServiceModel } from "io-functions-commons/dist/src/models/service"; -import { CustomTelemetryClientFactory } from "io-functions-commons/dist/src/utils/application_insights"; import { AzureApiAuthMiddleware, IAzureApiAuthorization, @@ -45,7 +44,6 @@ type IGetServiceHandler = ( >; export function GetServiceHandler( - _GCTC: CustomTelemetryClientFactory, serviceModel: ServiceModel ): IGetServiceHandler { return async (_, __, serviceId) => { @@ -77,11 +75,8 @@ export function GetServiceHandler( /** * Wraps a GetService handler inside an Express request handler. */ -export function GetService( - getCustomTelemetryClient: CustomTelemetryClientFactory, - serviceModel: ServiceModel -): express.RequestHandler { - const handler = GetServiceHandler(getCustomTelemetryClient, serviceModel); +export function GetService(serviceModel: ServiceModel): express.RequestHandler { + const handler = GetServiceHandler(serviceModel); const middlewaresWrap = withRequestMiddlewares( // Extract Azure Functions bindings diff --git a/GetService/index.ts b/GetService/index.ts index fb4a6c32..408e0b11 100755 --- a/GetService/index.ts +++ b/GetService/index.ts @@ -10,10 +10,6 @@ import { ServiceModel } from "io-functions-commons/dist/src/models/service"; -import { - TelemetryClient, - wrapCustomTelemetryClient -} from "io-functions-commons/dist/src/utils/application_insights"; import * as documentDbUtils from "io-functions-commons/dist/src/utils/documentdb"; import { getRequiredStringEnv } from "io-functions-commons/dist/src/utils/env"; import { secureExpressApp } from "io-functions-commons/dist/src/utils/express"; @@ -27,11 +23,6 @@ import { GetService } from "./handler"; // Whether we're in a production environment const isProduction = process.env.NODE_ENV === "production"; -const getCustomTelemetryClient = wrapCustomTelemetryClient( - isProduction, - new TelemetryClient() -); - const cosmosDbUri = getRequiredStringEnv("COSMOSDB_URI"); const cosmosDbKey = getRequiredStringEnv("COSMOSDB_KEY"); const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME"); @@ -60,10 +51,7 @@ const app = express(); secureExpressApp(app); // Add express route -app.get( - "/adm/services/:serviceid", - GetService(getCustomTelemetryClient, serviceModel) -); +app.get("/adm/services/:serviceid", GetService(serviceModel)); const azureFunctionHandler = createAzureFunctionHandler(app); diff --git a/UpdateService/__tests__/handler.test.ts b/UpdateService/__tests__/handler.test.ts index 358ce69b..d2877e89 100644 --- a/UpdateService/__tests__/handler.test.ts +++ b/UpdateService/__tests__/handler.test.ts @@ -43,10 +43,7 @@ describe("UpdateServiceHandler", () => { }) }; - const updateServiceHandler = UpdateServiceHandler( - undefined as any, // Not used - serviceModelMock as any - ); + const updateServiceHandler = UpdateServiceHandler(serviceModelMock as any); const response = await updateServiceHandler( undefined as any, // Not used @@ -71,10 +68,7 @@ describe("UpdateServiceHandler", () => { }) }; - const updateServiceHandler = UpdateServiceHandler( - undefined as any, // Not used - serviceModelMock as any - ); + const updateServiceHandler = UpdateServiceHandler(serviceModelMock as any); const response = await updateServiceHandler( undefined as any, // Not used @@ -100,10 +94,7 @@ describe("UpdateServiceHandler", () => { }) }; - const updateServiceHandler = UpdateServiceHandler( - undefined as any, // Not used - serviceModelMock as any - ); + const updateServiceHandler = UpdateServiceHandler(serviceModelMock as any); const response = await updateServiceHandler( undefined as any, // Not used @@ -132,10 +123,7 @@ describe("UpdateServiceHandler", () => { }) }; - const updateServiceHandler = UpdateServiceHandler( - undefined as any, // Not used - serviceModelMock as any - ); + const updateServiceHandler = UpdateServiceHandler(serviceModelMock as any); const response = await updateServiceHandler( undefined as any, // Not used @@ -165,10 +153,7 @@ describe("UpdateServiceHandler", () => { }) }; - const updateServiceHandler = UpdateServiceHandler( - undefined as any, // Not used - serviceModelMock as any - ); + const updateServiceHandler = UpdateServiceHandler(serviceModelMock as any); const response = await updateServiceHandler( undefined as any, // Not used @@ -199,10 +184,7 @@ describe("UpdateServiceHandler", () => { }) }; - const updateServiceHandler = UpdateServiceHandler( - undefined as any, // Not used - serviceModelMock as any - ); + const updateServiceHandler = UpdateServiceHandler(serviceModelMock as any); const response = await updateServiceHandler( undefined as any, // Not used @@ -243,10 +225,7 @@ describe("UpdateServiceHandler", () => { log: jest.fn() }; - const updateServiceHandler = UpdateServiceHandler( - undefined as any, - serviceModelMock as any - ); + const updateServiceHandler = UpdateServiceHandler(serviceModelMock as any); await updateServiceHandler( contextMock as any, // Not used diff --git a/UpdateService/handler.ts b/UpdateService/handler.ts index e785ef27..b9b4412d 100644 --- a/UpdateService/handler.ts +++ b/UpdateService/handler.ts @@ -21,7 +21,6 @@ import { import { Service as ApiService } from "io-functions-commons/dist/generated/definitions/Service"; import { ServiceId } from "io-functions-commons/dist/generated/definitions/ServiceId"; import { ServiceModel } from "io-functions-commons/dist/src/models/service"; -import { CustomTelemetryClientFactory } from "io-functions-commons/dist/src/utils/application_insights"; import { AzureApiAuthMiddleware, IAzureApiAuthorization, @@ -60,7 +59,6 @@ type IUpdateServiceHandler = ( >; export function UpdateServiceHandler( - _GCTC: CustomTelemetryClientFactory, serviceModel: ServiceModel ): IUpdateServiceHandler { return async (context, _, serviceId, servicePayload) => { @@ -140,10 +138,9 @@ export function UpdateServiceHandler( * Wraps a UpdateService handler inside an Express request handler. */ export function UpdateService( - getCustomTelemetryClient: CustomTelemetryClientFactory, serviceModel: ServiceModel ): express.RequestHandler { - const handler = UpdateServiceHandler(getCustomTelemetryClient, serviceModel); + const handler = UpdateServiceHandler(serviceModel); const middlewaresWrap = withRequestMiddlewares( // Extract Azure Functions bindings From c0b2cf2d98af85aff8933249ec4350be8bd60f80 Mon Sep 17 00:00:00 2001 From: Emanuele De Cupis Date: Fri, 8 May 2020 10:39:09 +0200 Subject: [PATCH 3/3] fix lint --- CreateService/index.ts | 3 --- GetService/index.ts | 3 --- UpdateService/index.ts | 17 +---------------- package.json | 2 +- 4 files changed, 2 insertions(+), 23 deletions(-) diff --git a/CreateService/index.ts b/CreateService/index.ts index a3a9e74d..d6a8b244 100755 --- a/CreateService/index.ts +++ b/CreateService/index.ts @@ -20,9 +20,6 @@ import createAzureFunctionHandler from "io-functions-express/dist/src/createAzur import { CreateService } from "./handler"; -// Whether we're in a production environment -const isProduction = process.env.NODE_ENV === "production"; - const cosmosDbUri = getRequiredStringEnv("COSMOSDB_URI"); const cosmosDbKey = getRequiredStringEnv("COSMOSDB_KEY"); const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME"); diff --git a/GetService/index.ts b/GetService/index.ts index 408e0b11..d7cf1428 100755 --- a/GetService/index.ts +++ b/GetService/index.ts @@ -20,9 +20,6 @@ import createAzureFunctionHandler from "io-functions-express/dist/src/createAzur import { GetService } from "./handler"; -// Whether we're in a production environment -const isProduction = process.env.NODE_ENV === "production"; - const cosmosDbUri = getRequiredStringEnv("COSMOSDB_URI"); const cosmosDbKey = getRequiredStringEnv("COSMOSDB_KEY"); const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME"); diff --git a/UpdateService/index.ts b/UpdateService/index.ts index d9899189..b4e79e01 100755 --- a/UpdateService/index.ts +++ b/UpdateService/index.ts @@ -10,10 +10,6 @@ import { ServiceModel } from "io-functions-commons/dist/src/models/service"; -import { - TelemetryClient, - wrapCustomTelemetryClient -} from "io-functions-commons/dist/src/utils/application_insights"; import * as documentDbUtils from "io-functions-commons/dist/src/utils/documentdb"; import { getRequiredStringEnv } from "io-functions-commons/dist/src/utils/env"; import { secureExpressApp } from "io-functions-commons/dist/src/utils/express"; @@ -24,14 +20,6 @@ import createAzureFunctionHandler from "io-functions-express/dist/src/createAzur import { UpdateService } from "./handler"; -// Whether we're in a production environment -const isProduction = process.env.NODE_ENV === "production"; - -const getCustomTelemetryClient = wrapCustomTelemetryClient( - isProduction, - new TelemetryClient() -); - const cosmosDbUri = getRequiredStringEnv("COSMOSDB_URI"); const cosmosDbKey = getRequiredStringEnv("COSMOSDB_KEY"); const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME"); @@ -60,10 +48,7 @@ const app = express(); secureExpressApp(app); // Add express route -app.put( - "/adm/services/:serviceid", - UpdateService(getCustomTelemetryClient, serviceModel) -); +app.put("/adm/services/:serviceid", UpdateService(serviceModel)); const azureFunctionHandler = createAzureFunctionHandler(app); diff --git a/package.json b/package.json index ea753caa..7b968ea1 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "prestart": "npm run build && func extensions install", "start:host": "func start", "start": "npm-run-all --parallel start:host watch", - "_pretest": "yarn generate:definitions", + "pretest": "yarn generate:definitions", "test": "dotenv -e env.example -- jest", "pretest:coverage": "yarn generate:definitions", "test:coverage": "dotenv -e env.example -- jest --coverage",