From: Jérôme Benoit Date: Thu, 12 May 2022 19:41:10 +0000 (+0200) Subject: Make the UI server request handler signature more generic X-Git-Tag: v1.1.60~15 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=178ac666dd23c1fe11b2b800afeafaa4e8dd7a1c;p=e-mobility-charging-stations-simulator.git Make the UI server request handler signature more generic Signed-off-by: Jérôme Benoit --- diff --git a/package-lock.json b/package-lock.json index ed27767b..15c3d84d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "chalk": "^4.1.2", "express": "^4.18.1", "moment": "^2.29.3", - "mongodb": "^4.5.0", + "mongodb": "^4.6.0", "poolifier": "^2.2.0", "proper-lockfile": "^4.1.2", "source-map-support": "^0.5.21", @@ -1019,9 +1019,9 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.10.tgz", - "integrity": "sha512-Q0YbBd6OTsXm8Y21+YUSDXupHnodNC2M4O18jtd3iwJ3+vMZNdKGols0a9G6JOK0dcJ3IdUUHoh908ZI6qhk8Q==", + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz", + "integrity": "sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w==", "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", @@ -1048,9 +1048,9 @@ } }, "node_modules/@mdn/browser-compat-data": { - "version": "4.1.19", - "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-4.1.19.tgz", - "integrity": "sha512-zDrdjvX2dwunW4HOGwpibLHvfnDRQOJ89bGnkQ7TXZ7H7JSehbg2Gf0zNbML+R/03QItZ7EI6QHloOJ2znFSdA==", + "version": "4.1.20", + "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-4.1.20.tgz", + "integrity": "sha512-9VOi5TU0xE/XhShmGQpNAa3PduouSxDrEK0p7mVZe4ndhH8xV87fYb3vyYyL8i4wyRT7fHG8vyecVTRMLy04Mg==", "dev": true }, "node_modules/@mikro-orm/cli": { @@ -1834,9 +1834,9 @@ } }, "node_modules/@types/node": { - "version": "16.11.33", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.33.tgz", - "integrity": "sha512-0PJ0vg+JyU0MIan58IOIFRtSvsb7Ri+7Wltx2qAg94eMOrpg4+uuP3aUHCpxXc1i0jCXiC+zIamSZh3l9AbcQA==" + "version": "16.11.34", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.34.tgz", + "integrity": "sha512-UrWGDyLAlQ2Z8bNOGWTsqbP9ZcBeTYBVuTRNxXTztBy5KhWUFI3BaeDWoCP/CzV/EVGgO1NTYzv9ZytBI9GAEw==" }, "node_modules/@types/object-path": { "version": "0.11.1", @@ -3560,9 +3560,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001338", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001338.tgz", - "integrity": "sha512-1gLHWyfVoRDsHieO+CaeYe7jSo/MT7D7lhaXUiwwbuR5BwQxORs0f1tAwUSQr3YbxRXJvxHM/PA5FfPQRnsPeQ==", + "version": "1.0.30001340", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001340.tgz", + "integrity": "sha512-jUNz+a9blQTQVu4uFcn17uAD8IDizPzQkIKh3LCJfg9BkyIqExYYdyc/ZSlWUSKb8iYiXxKsxbv4zYSvkqjrxw==", "dev": true, "funding": [ { @@ -3662,9 +3662,9 @@ } }, "node_modules/ci-info": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.0.tgz", - "integrity": "sha512-riT/3vI5YpVH6/qomlDnJow6TBee2PBKSEpx3O32EGPYbWGIRsIlGRms3Sm74wYE1JMo8RnO04Hb12+v1J5ICw==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.1.tgz", + "integrity": "sha512-SXgeMX9VwDe7iFFaEWkA5AstuER9YKqy4EhHqr4DVqkwmD9rpVimkMKWHdjn30Ja45txyjhSn63lVX69eVCckg==", "dev": true }, "node_modules/cipher-base": { @@ -6389,9 +6389,9 @@ } }, "node_modules/filelist": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.3.tgz", - "integrity": "sha512-LwjCsruLWQULGYKy7TX0OPtrL9kLpojOFKc5VCTxdFTV7w5zbsgqVKfnkKG7Qgjtq50gKfO56hJv88OfcGb70Q==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", "dev": true, "dependencies": { "minimatch": "^5.0.1" @@ -6546,9 +6546,9 @@ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==" }, "node_modules/foreach": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.6.tgz", + "integrity": "sha512-k6GAGDyqLe9JaebCsFCoudPPWfihKu8pylYXRlqP1J7ms39iPoTtk2fviNglIeQEwdh0bQeKJ01ZPyuyQvKzwg==", "dev": true }, "node_modules/foreground-child": { @@ -7011,9 +7011,9 @@ } }, "node_modules/globals": { - "version": "13.14.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.14.0.tgz", - "integrity": "sha512-ERO68sOYwm5UuLvSJTY7w7NP2c8S4UcXs3X1GBX8cwOr+ShOcDBbCY5mH4zxz0jsYCdJ8ve8Mv9n2YGJMB1aeg==", + "version": "13.15.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.15.0.tgz", + "integrity": "sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -8028,9 +8028,9 @@ "dev": true }, "node_modules/ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", + "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==" }, "node_modules/ip-regex": { "version": "2.1.0", @@ -9005,12 +9005,12 @@ } }, "node_modules/keyv": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.2.2.tgz", - "integrity": "sha512-uYS0vKTlBIjNCAUqrjlxmruxOEiZxZIHXyp32sdcGmP+ukFrmWUnE//RcPXJH3Vxrni1H2gsQbjHE0bH7MtMQQ==", + "version": "4.2.7", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.2.7.tgz", + "integrity": "sha512-HeOstD8SXvtWoQhMMBCelcUuZsiV7T7MwsADtOXT0KuwYP9nCxrSoMDeLXNDTLN3VFSuRp38JzoGbbTboq3QQw==", "dev": true, "dependencies": { - "compress-brotli": "^1.3.6", + "compress-brotli": "^1.3.8", "json-buffer": "3.0.1" } }, @@ -9557,9 +9557,9 @@ } }, "node_modules/magic-string": { - "version": "0.26.1", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.1.tgz", - "integrity": "sha512-ndThHmvgtieXe8J/VGPjG+Apu7v7ItcD5mhEIvOscWjPF/ccOiLxHaSuCAS2G+3x4GKsAbT8u7zdyamupui8Tg==", + "version": "0.26.2", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.2.tgz", + "integrity": "sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==", "dev": true, "dependencies": { "sourcemap-codec": "^1.4.8" @@ -9679,9 +9679,9 @@ } }, "node_modules/mariadb/node_modules/@types/node": { - "version": "17.0.31", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz", - "integrity": "sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q==" + "version": "17.0.32", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.32.tgz", + "integrity": "sha512-eAIcfAvhf/BkHcf4pkLJ7ECpBAhh9kcxRBpip9cTiO+hf+aJrsxYxBeS6OXvOd9WqNAJmavXVpZvY1rBjNsXmw==" }, "node_modules/mariadb/node_modules/iconv-lite": { "version": "0.6.3", @@ -10372,9 +10372,9 @@ } }, "node_modules/mochawesome-report-generator/node_modules/yargs": { - "version": "17.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.4.1.tgz", - "integrity": "sha512-WSZD9jgobAg3ZKuCQZSa3g9QOJeCCqLoLAykiWgmXnDo9EPnn4RPf5qVTtzgOx66o6/oqhcA5tHtJXpG8pMt3g==", + "version": "17.5.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.0.tgz", + "integrity": "sha512-3sLxVhbAB5OC8qvVRebCLWuouhwh/rswsiDYx3WGxajUk/l4G20SKfrKKFeNIHboUFt2JFgv2yfn+5cgOr/t5A==", "dev": true, "dependencies": { "cliui": "^7.0.2", @@ -10462,11 +10462,11 @@ } }, "node_modules/mongodb": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.5.0.tgz", - "integrity": "sha512-A2l8MjEpKojnhbCM0MK3+UOGUSGvTNNSv7AkP1fsT7tkambrkkqN/5F2y+PhzsV0Nbv58u04TETpkaSEdI2zKA==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.6.0.tgz", + "integrity": "sha512-1gsxVXmjFTPJ+CkMG9olE4bcVsyY8lBJN9m5B5vj+LZ7wkBqq3PO8RVmNX9GwCBOBz1KV0zM00vPviUearSv7A==", "dependencies": { - "bson": "^4.6.2", + "bson": "^4.6.3", "denque": "^2.0.1", "mongodb-connection-string-url": "^2.5.2", "socks": "^2.6.2" @@ -16134,9 +16134,9 @@ } }, "node_modules/uglify-js": { - "version": "3.15.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.4.tgz", - "integrity": "sha512-vMOPGDuvXecPs34V74qDKk4iJ/SN4vL3Ow/23ixafENYvtrNvtbcgUeugTcUGRGsOF/5fU8/NYSL5Hyb3l1OJA==", + "version": "3.15.5", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.5.tgz", + "integrity": "sha512-hNM5q5GbBRB5xB+PMqVRcgYe4c8jbyZ1pzZhS6jbq54/4F2gFK869ZheiE5A8/t+W5jtTNpWef/5Q9zk639FNQ==", "dev": true, "optional": true, "bin": { @@ -17954,9 +17954,9 @@ "dev": true }, "@jridgewell/trace-mapping": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.10.tgz", - "integrity": "sha512-Q0YbBd6OTsXm8Y21+YUSDXupHnodNC2M4O18jtd3iwJ3+vMZNdKGols0a9G6JOK0dcJ3IdUUHoh908ZI6qhk8Q==", + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz", + "integrity": "sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w==", "dev": true, "requires": { "@jridgewell/resolve-uri": "^3.0.3", @@ -17980,9 +17980,9 @@ } }, "@mdn/browser-compat-data": { - "version": "4.1.19", - "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-4.1.19.tgz", - "integrity": "sha512-zDrdjvX2dwunW4HOGwpibLHvfnDRQOJ89bGnkQ7TXZ7H7JSehbg2Gf0zNbML+R/03QItZ7EI6QHloOJ2znFSdA==", + "version": "4.1.20", + "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-4.1.20.tgz", + "integrity": "sha512-9VOi5TU0xE/XhShmGQpNAa3PduouSxDrEK0p7mVZe4ndhH8xV87fYb3vyYyL8i4wyRT7fHG8vyecVTRMLy04Mg==", "dev": true }, "@mikro-orm/cli": { @@ -18537,9 +18537,9 @@ } }, "@types/node": { - "version": "16.11.33", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.33.tgz", - "integrity": "sha512-0PJ0vg+JyU0MIan58IOIFRtSvsb7Ri+7Wltx2qAg94eMOrpg4+uuP3aUHCpxXc1i0jCXiC+zIamSZh3l9AbcQA==" + "version": "16.11.34", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.34.tgz", + "integrity": "sha512-UrWGDyLAlQ2Z8bNOGWTsqbP9ZcBeTYBVuTRNxXTztBy5KhWUFI3BaeDWoCP/CzV/EVGgO1NTYzv9ZytBI9GAEw==" }, "@types/object-path": { "version": "0.11.1", @@ -19916,9 +19916,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001338", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001338.tgz", - "integrity": "sha512-1gLHWyfVoRDsHieO+CaeYe7jSo/MT7D7lhaXUiwwbuR5BwQxORs0f1tAwUSQr3YbxRXJvxHM/PA5FfPQRnsPeQ==", + "version": "1.0.30001340", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001340.tgz", + "integrity": "sha512-jUNz+a9blQTQVu4uFcn17uAD8IDizPzQkIKh3LCJfg9BkyIqExYYdyc/ZSlWUSKb8iYiXxKsxbv4zYSvkqjrxw==", "dev": true }, "caseless": { @@ -19987,9 +19987,9 @@ "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" }, "ci-info": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.0.tgz", - "integrity": "sha512-riT/3vI5YpVH6/qomlDnJow6TBee2PBKSEpx3O32EGPYbWGIRsIlGRms3Sm74wYE1JMo8RnO04Hb12+v1J5ICw==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.1.tgz", + "integrity": "sha512-SXgeMX9VwDe7iFFaEWkA5AstuER9YKqy4EhHqr4DVqkwmD9rpVimkMKWHdjn30Ja45txyjhSn63lVX69eVCckg==", "dev": true }, "cipher-base": { @@ -22240,9 +22240,9 @@ "dev": true }, "filelist": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.3.tgz", - "integrity": "sha512-LwjCsruLWQULGYKy7TX0OPtrL9kLpojOFKc5VCTxdFTV7w5zbsgqVKfnkKG7Qgjtq50gKfO56hJv88OfcGb70Q==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", "dev": true, "requires": { "minimatch": "^5.0.1" @@ -22374,9 +22374,9 @@ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==" }, "foreach": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.6.tgz", + "integrity": "sha512-k6GAGDyqLe9JaebCsFCoudPPWfihKu8pylYXRlqP1J7ms39iPoTtk2fviNglIeQEwdh0bQeKJ01ZPyuyQvKzwg==", "dev": true }, "foreground-child": { @@ -22738,9 +22738,9 @@ } }, "globals": { - "version": "13.14.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.14.0.tgz", - "integrity": "sha512-ERO68sOYwm5UuLvSJTY7w7NP2c8S4UcXs3X1GBX8cwOr+ShOcDBbCY5mH4zxz0jsYCdJ8ve8Mv9n2YGJMB1aeg==", + "version": "13.15.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.15.0.tgz", + "integrity": "sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -23533,9 +23533,9 @@ "dev": true }, "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", + "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==" }, "ip-regex": { "version": "2.1.0", @@ -24245,12 +24245,12 @@ } }, "keyv": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.2.2.tgz", - "integrity": "sha512-uYS0vKTlBIjNCAUqrjlxmruxOEiZxZIHXyp32sdcGmP+ukFrmWUnE//RcPXJH3Vxrni1H2gsQbjHE0bH7MtMQQ==", + "version": "4.2.7", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.2.7.tgz", + "integrity": "sha512-HeOstD8SXvtWoQhMMBCelcUuZsiV7T7MwsADtOXT0KuwYP9nCxrSoMDeLXNDTLN3VFSuRp38JzoGbbTboq3QQw==", "dev": true, "requires": { - "compress-brotli": "^1.3.6", + "compress-brotli": "^1.3.8", "json-buffer": "3.0.1" } }, @@ -24657,9 +24657,9 @@ "dev": true }, "magic-string": { - "version": "0.26.1", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.1.tgz", - "integrity": "sha512-ndThHmvgtieXe8J/VGPjG+Apu7v7ItcD5mhEIvOscWjPF/ccOiLxHaSuCAS2G+3x4GKsAbT8u7zdyamupui8Tg==", + "version": "0.26.2", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.2.tgz", + "integrity": "sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==", "dev": true, "requires": { "sourcemap-codec": "^1.4.8" @@ -24759,9 +24759,9 @@ }, "dependencies": { "@types/node": { - "version": "17.0.31", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz", - "integrity": "sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q==" + "version": "17.0.32", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.32.tgz", + "integrity": "sha512-eAIcfAvhf/BkHcf4pkLJ7ECpBAhh9kcxRBpip9cTiO+hf+aJrsxYxBeS6OXvOd9WqNAJmavXVpZvY1rBjNsXmw==" }, "iconv-lite": { "version": "0.6.3", @@ -25322,9 +25322,9 @@ "dev": true }, "yargs": { - "version": "17.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.4.1.tgz", - "integrity": "sha512-WSZD9jgobAg3ZKuCQZSa3g9QOJeCCqLoLAykiWgmXnDo9EPnn4RPf5qVTtzgOx66o6/oqhcA5tHtJXpG8pMt3g==", + "version": "17.5.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.0.tgz", + "integrity": "sha512-3sLxVhbAB5OC8qvVRebCLWuouhwh/rswsiDYx3WGxajUk/l4G20SKfrKKFeNIHboUFt2JFgv2yfn+5cgOr/t5A==", "dev": true, "requires": { "cliui": "^7.0.2", @@ -25395,11 +25395,11 @@ } }, "mongodb": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.5.0.tgz", - "integrity": "sha512-A2l8MjEpKojnhbCM0MK3+UOGUSGvTNNSv7AkP1fsT7tkambrkkqN/5F2y+PhzsV0Nbv58u04TETpkaSEdI2zKA==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.6.0.tgz", + "integrity": "sha512-1gsxVXmjFTPJ+CkMG9olE4bcVsyY8lBJN9m5B5vj+LZ7wkBqq3PO8RVmNX9GwCBOBz1KV0zM00vPviUearSv7A==", "requires": { - "bson": "^4.6.2", + "bson": "^4.6.3", "denque": "^2.0.1", "mongodb-connection-string-url": "^2.5.2", "saslprep": "^1.0.3", @@ -29765,9 +29765,9 @@ "dev": true }, "uglify-js": { - "version": "3.15.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.4.tgz", - "integrity": "sha512-vMOPGDuvXecPs34V74qDKk4iJ/SN4vL3Ow/23ixafENYvtrNvtbcgUeugTcUGRGsOF/5fU8/NYSL5Hyb3l1OJA==", + "version": "3.15.5", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.5.tgz", + "integrity": "sha512-hNM5q5GbBRB5xB+PMqVRcgYe4c8jbyZ1pzZhS6jbq54/4F2gFK869ZheiE5A8/t+W5jtTNpWef/5Q9zk639FNQ==", "dev": true, "optional": true }, diff --git a/package.json b/package.json index 874821f4..cfb1ea24 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "chalk": "^4.1.2", "express": "^4.18.1", "moment": "^2.29.3", - "mongodb": "^4.5.0", + "mongodb": "^4.6.0", "poolifier": "^2.2.0", "proper-lockfile": "^4.1.2", "source-map-support": "^0.5.21", diff --git a/src/charging-station/UIWebSocketServer.ts b/src/charging-station/UIWebSocketServer.ts index 11069551..424ab8c9 100644 --- a/src/charging-station/UIWebSocketServer.ts +++ b/src/charging-station/UIWebSocketServer.ts @@ -1,8 +1,7 @@ -import { Protocol, ProtocolCommand, ProtocolRequest, ProtocolVersion } from '../types/UIProtocol'; +import { Protocol, ProtocolVersion } from '../types/UIProtocol'; import WebSocket, { OPEN, Server, ServerOptions } from 'ws'; import AbstractUIService from './ui-websocket-services/AbstractUIService'; -import BaseError from '../exception/BaseError'; import Configuration from '../utils/Configuration'; import { IncomingMessage } from 'http'; import UIServiceFactory from './ui-websocket-services/UIServiceFactory'; @@ -18,17 +17,6 @@ export default class UIWebSocketServer extends Server { super(options ?? Configuration.getUIWebSocketServer().options, callback); this.chargingStations = new Set(); this.uiServices = new Map(); - for (const version of Object.values(ProtocolVersion)) { - this.uiServices.set(version, UIServiceFactory.getUIServiceImplementation(version, this)); - } - } - - public broadcastToClients(message: string): void { - for (const client of this.clients) { - if (client?.readyState === OPEN) { - client.send(message); - } - } } public start(): void { @@ -38,28 +26,15 @@ export default class UIWebSocketServer extends Server { protocolIndex + Protocol.UI.length ) as ProtocolVersion; if (!this.uiServices.has(version)) { - throw new BaseError( - `Could not find a UI service implementation for UI protocol version ${version}` - ); + this.uiServices.set(version, UIServiceFactory.getUIServiceImplementation(version, this)); } // FIXME: check connection validity socket.on('message', (messageData) => { - let [command, payload]: ProtocolRequest = [ProtocolCommand.UNKNOWN, {}]; - const protocolRequest = JSON.parse(messageData.toString()) as ProtocolRequest; - if (Utils.isIterable(protocolRequest)) { - [command, payload] = protocolRequest; - } else { - throw new BaseError('UI protocol request is not iterable'); - } this.uiServices .get(version) - .messageHandler(command, payload) + .messageHandler(messageData) .catch(() => { - logger.error( - `${this.logPrefix()} Error while handling command %s message: %j`, - command, - payload - ); + logger.error(`${this.logPrefix()} Error while handling message data: %j`, messageData); }); }); socket.on('error', (error) => { @@ -72,7 +47,19 @@ export default class UIWebSocketServer extends Server { this.close(); } + public sendResponse(message: string): void { + this.broadcastToClients(message); + } + public logPrefix(): string { return Utils.logPrefix(' UI WebSocket Server:'); } + + private broadcastToClients(message: string): void { + for (const client of this.clients) { + if (client?.readyState === OPEN) { + client.send(message); + } + } + } } diff --git a/src/charging-station/ui-websocket-services/AbstractUIService.ts b/src/charging-station/ui-websocket-services/AbstractUIService.ts index 42cfa428..f8de1be5 100644 --- a/src/charging-station/ui-websocket-services/AbstractUIService.ts +++ b/src/charging-station/ui-websocket-services/AbstractUIService.ts @@ -1,8 +1,10 @@ -import { ProtocolCommand, ProtocolRequestHandler } from '../../types/UIProtocol'; +import { ProtocolCommand, ProtocolRequest, ProtocolRequestHandler } from '../../types/UIProtocol'; import BaseError from '../../exception/BaseError'; import { JsonType } from '../../types/JsonType'; +import { RawData } from 'ws'; import UIWebSocketServer from '../UIWebSocketServer'; +import Utils from '../../utils/Utils'; import logger from '../../utils/Logger'; export default abstract class AbstractUIService { @@ -16,11 +18,19 @@ export default abstract class AbstractUIService { ]); } - public async messageHandler(command: ProtocolCommand, payload: JsonType): Promise { + public async messageHandler(request: RawData): Promise { + let command: ProtocolCommand; + let payload: JsonType; + const protocolRequest = JSON.parse(request.toString()) as ProtocolRequest; + if (Utils.isIterable(protocolRequest)) { + [command, payload] = protocolRequest; + } else { + throw new BaseError('UI protocol request is not iterable'); + } let messageResponse: JsonType; if (this.messageHandlers.has(command)) { try { - // Call the method to build the message response + // Call the message handler to build the message response messageResponse = (await this.messageHandlers.get(command)(payload)) as JsonType; } catch (error) { // Log @@ -37,15 +47,15 @@ export default abstract class AbstractUIService { )}` ); } - // Send the built message response - this.uiWebSocketServer.broadcastToClients(this.buildProtocolMessage(command, messageResponse)); + // Send the message response + this.uiWebSocketServer.sendResponse(this.buildProtocolMessage(command, messageResponse)); } protected buildProtocolMessage(command: ProtocolCommand, payload: JsonType): string { return JSON.stringify([command, payload]); } - private handleListChargingStations(): string[] { + private handleListChargingStations(): JsonType { return Array.from(this.uiWebSocketServer.chargingStations); } } diff --git a/src/types/UIProtocol.ts b/src/types/UIProtocol.ts index 6d247892..4344c0d6 100644 --- a/src/types/UIProtocol.ts +++ b/src/types/UIProtocol.ts @@ -12,7 +12,6 @@ export enum ProtocolCommand { LIST_CHARGING_STATIONS = 'listChargingStations', START_TRANSACTION = 'startTransaction', STOP_TRANSACTION = 'stopTransaction', - UNKNOWN = 'unknown', } export type ProtocolRequest = [ProtocolCommand, JsonType];