From 9deb0064b08034747ac6c7f9db14db13291b8705 Mon Sep 17 00:00:00 2001 From: KristianFJones Date: Fri, 12 Jun 2020 02:27:21 +0000 Subject: [PATCH] feat: Port from Express to Fastify --- package-lock.json | 654 +++++++------------ package.json | 4 +- src/Lab/Auth.ts | 89 --- src/Lab/Library/Fastify.ts | 103 +++ src/Lab/Modules/Auth/AuthRoute.ts | 26 + src/Lab/Modules/Auth/LoginPageRoute.ts | 44 ++ src/Lab/Modules/Auth/LoginRoute.ts | 34 + src/Lab/Modules/Auth/TokenRoute.ts | 47 ++ src/Lab/Utils/moduleFileFinder.ts | 43 ++ src/Lab/Utils/resolvePath.ts | 12 + src/Lab/index.ts | 25 +- src/Modules/Controller/Controller.ts | 3 - src/Modules/Controller/index.ts | 1 - src/Modules/SmartHome/SmartHomeController.ts | 57 +- 14 files changed, 598 insertions(+), 544 deletions(-) delete mode 100644 src/Lab/Auth.ts create mode 100644 src/Lab/Library/Fastify.ts create mode 100644 src/Lab/Modules/Auth/AuthRoute.ts create mode 100644 src/Lab/Modules/Auth/LoginPageRoute.ts create mode 100644 src/Lab/Modules/Auth/LoginRoute.ts create mode 100644 src/Lab/Modules/Auth/TokenRoute.ts create mode 100644 src/Lab/Utils/moduleFileFinder.ts create mode 100644 src/Lab/Utils/resolvePath.ts delete mode 100644 src/Modules/Controller/Controller.ts delete mode 100644 src/Modules/Controller/index.ts diff --git a/package-lock.json b/package-lock.json index 108787e..e83a625 100644 --- a/package-lock.json +++ b/package-lock.json @@ -840,14 +840,10 @@ "event-target-shim": "^5.0.0" } }, - "accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", - "requires": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" - } + "abstract-logging": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.0.tgz", + "integrity": "sha512-/oA9z7JszpIioo6J6dB79LVUgJ3eD3cxkAmdCkvWWS+Y9tPtALs1rLqOekLUXUbYqM2fB9TTK0ibAyZJJOP/CA==" }, "acorn": { "version": "7.2.0", @@ -1078,7 +1074,6 @@ "version": "6.12.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz", "integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==", - "dev": true, "requires": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -1168,6 +1163,11 @@ "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true }, + "archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=" + }, "are-we-there-yet": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", @@ -1199,11 +1199,6 @@ "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", "dev": true }, - "array-flatten": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" - }, "array-includes": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz", @@ -1259,6 +1254,11 @@ "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true }, + "atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==" + }, "ava": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/ava/-/ava-2.4.0.tgz", @@ -1728,6 +1728,16 @@ } } }, + "avvio": { + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/avvio/-/avvio-6.4.1.tgz", + "integrity": "sha512-jeZaUK+F7MuWSNT3VHfltskPJZKqVeTWQqBA4SDaDoLaQ0lb5TOgLeQT1BEuhTIUNISCDCGY3zjYyVmQQ48gKA==", + "requires": { + "archy": "^1.0.0", + "debug": "^4.0.0", + "fastq": "^1.6.0" + } + }, "axios": { "version": "0.18.1", "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz", @@ -1798,43 +1808,6 @@ "integrity": "sha512-j4nzWIqEFpLSbdhUApHRGDwfXbV8ALhqOn+FY5L6XBdKPAXU9BpGgFSbDsgqogfqPPR9R2WooseWCsfhfEC6uQ==", "dev": true }, - "body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", - "requires": { - "bytes": "3.1.0", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "1.7.2", - "iconv-lite": "0.4.24", - "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" - } - } - }, "boxen": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/boxen/-/boxen-4.2.0.tgz", @@ -1951,11 +1924,6 @@ } } }, - "bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" - }, "cacheable-request": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz", @@ -2407,26 +2375,6 @@ "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", "dev": true }, - "content-disposition": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", - "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", - "requires": { - "safe-buffer": "5.1.2" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - } - } - }, - "content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" - }, "convert-source-map": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", @@ -2455,11 +2403,6 @@ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" }, - "cookie-signature": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" - }, "core-js": { "version": "2.6.11", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz", @@ -2511,7 +2454,6 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, "requires": { "ms": "^2.1.1" } @@ -2575,6 +2517,11 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==" + }, "defaults": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", @@ -2664,16 +2611,6 @@ "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "dev": true }, - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" - }, - "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" - }, "detect-libc": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", @@ -2736,11 +2673,6 @@ "safe-buffer": "^5.0.1" } }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" - }, "emittery": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.4.1.tgz", @@ -2763,11 +2695,6 @@ "core-js": "^2.0.0" } }, - "encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" - }, "end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -2849,11 +2776,6 @@ "integrity": "sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q==", "dev": true }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -3257,11 +3179,6 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, - "etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" - }, "event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -3332,68 +3249,6 @@ } } }, - "express": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", - "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", - "requires": { - "accepts": "~1.3.7", - "array-flatten": "1.1.1", - "body-parser": "1.19.0", - "content-disposition": "0.5.3", - "content-type": "~1.0.4", - "cookie": "0.4.0", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "~1.1.2", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "~1.1.2", - "fresh": "0.5.2", - "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "~2.3.0", - "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.5", - "qs": "6.7.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.1.2", - "send": "0.17.1", - "serve-static": "1.14.1", - "setprototypeof": "1.1.1", - "statuses": "~1.5.0", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - } - } - }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -3411,11 +3266,15 @@ "tmp": "^0.0.33" } }, + "fast-decode-uri-component": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz", + "integrity": "sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==" + }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "fast-diff": { "version": "1.2.0", @@ -3440,8 +3299,17 @@ "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, + "fast-json-stringify": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-1.20.1.tgz", + "integrity": "sha512-PEPWrRZvKqI11fY2uDhLLuoapIda9wVQ2mzAj8rkBfVD7jWvOSIICL0Om1knoReIWKF5y/5bbR/GzcZANaaJfQ==", + "requires": { + "ajv": "^6.11.0", + "deepmerge": "^4.2.2", + "string-similarity": "^4.0.1" + } }, "fast-levenshtein": { "version": "2.0.6", @@ -3449,17 +3317,76 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fast-redact": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-2.0.0.tgz", + "integrity": "sha512-zxpkULI9W9MNTK2sJ3BpPQrTEXFNESd2X6O1tXMFpK/XM0G5c5Rll2EVYZH2TqI3xRGK/VaJ+eEOt7pnENJpeA==" + }, + "fast-safe-stringify": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", + "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==" + }, "fast-text-encoding": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.2.tgz", "integrity": "sha512-5rQdinSsycpzvAoHga2EDn+LRX1d5xLFsuNG0Kg61JrAT/tASXcLL0nf/33v+sAxlQcfYmWbTURa1mmAf55jGw==", "dev": true }, + "fastify": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/fastify/-/fastify-2.14.1.tgz", + "integrity": "sha512-nSL8AgIdFCpZmFwjqB5Zzv+3/1KpwwVtB/h88Q4Og8njYbkddKGpuQlQ2tHUULXPTJrLZ7wop6olzx6HEbHdpw==", + "requires": { + "abstract-logging": "^2.0.0", + "ajv": "^6.12.0", + "avvio": "^6.3.1", + "fast-json-stringify": "^1.18.0", + "find-my-way": "^2.2.2", + "flatstr": "^1.0.12", + "light-my-request": "^3.7.3", + "middie": "^4.1.0", + "pino": "^5.17.0", + "proxy-addr": "^2.0.6", + "readable-stream": "^3.6.0", + "rfdc": "^1.1.2", + "secure-json-parse": "^2.1.0", + "tiny-lru": "^7.0.2" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, + "fastify-formbody": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fastify-formbody/-/fastify-formbody-3.2.0.tgz", + "integrity": "sha512-/QGuH5RGbDwsEaMzS2cyxWh+cqC42w39ZcvOmdQsNW0s4F4ubfp0De4jY3hLVRk4HeeDsF/YCDgH6pKb/PuKjA==", + "requires": { + "fastify-plugin": "^1.6.1", + "qs": "^6.9.4" + } + }, + "fastify-plugin": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-1.6.1.tgz", + "integrity": "sha512-APBcb27s+MjaBIerFirYmBLatoPCgmHZM6XP0K+nDL9k0yX8NJPWDY1RAC3bh6z+AB5ULS2j31BUfLMT3uaZ4A==", + "requires": { + "semver": "^6.3.0" + } + }, "fastq": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.8.0.tgz", "integrity": "sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q==", - "dev": true, "requires": { "reusify": "^1.0.4" } @@ -3491,33 +3418,14 @@ "to-regex-range": "^5.0.1" } }, - "finalhandler": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", - "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", - "requires": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "~2.3.0", - "parseurl": "~1.3.3", - "statuses": "~1.5.0", - "unpipe": "~1.0.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - } + "find-my-way": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-2.2.3.tgz", + "integrity": "sha512-C7dxfbX8pV1maLd31ygkBEOaD51Ls4dROuHjeSQZf1FeQinUzq3UA/kSPecLSDy9iAQufd8w1zgp7j64kyLdhw==", + "requires": { + "fast-decode-uri-component": "^1.0.0", + "safe-regex2": "^2.0.0", + "semver-store": "^0.3.0" } }, "find-up": { @@ -3540,6 +3448,11 @@ "write": "1.0.3" } }, + "flatstr": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/flatstr/-/flatstr-1.0.12.tgz", + "integrity": "sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw==" + }, "flatted": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", @@ -3577,11 +3490,6 @@ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" }, - "fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" - }, "fs-minipass": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", @@ -4092,25 +4000,6 @@ "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", "dev": true }, - "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" - }, - "dependencies": { - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - } - } - }, "https-proxy-agent": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", @@ -4158,6 +4047,7 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -4294,8 +4184,7 @@ "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ini": { "version": "1.3.5", @@ -4688,8 +4577,7 @@ "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -4764,6 +4652,29 @@ "type-check": "~0.4.0" } }, + "light-my-request": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-3.8.0.tgz", + "integrity": "sha512-cIOWmNsgoStysmkzcv2EwvLwMb2hEm6oqKMerG/b5ey9F0we2Qony8cAZgBktmGPYUvPyKsDCzMcYU6fXbpWew==", + "requires": { + "ajv": "^6.10.2", + "cookie": "^0.4.0", + "readable-stream": "^3.4.0", + "set-cookie-parser": "^2.4.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "load-json-file": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", @@ -4947,11 +4858,6 @@ "integrity": "sha1-givM1l4RfFFPqxdrJZRdVBAKA8M=", "dev": true }, - "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" - }, "meow": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/meow/-/meow-5.0.0.tgz", @@ -5039,11 +4945,6 @@ } } }, - "merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" - }, "merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -5084,11 +4985,6 @@ "integrity": "sha512-2fU3XDCanRqeOCkn7R5zW5VQHWf+T3hH65SzuqRvjatBK7r4uyFa5mEX+k6F9Bd04LVM5G4/BHBTUJsOdW7uyg==", "dev": true }, - "methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" - }, "micromatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", @@ -5099,25 +4995,28 @@ "picomatch": "^2.0.5" } }, + "middie": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/middie/-/middie-4.1.0.tgz", + "integrity": "sha512-eylPpZA+K3xO9kpDjagoPkEUkNcWV3EAo5OEz0MqsekUpT7KbnQkk8HNZkh4phx2vvOAmNNZuLRWF9lDDHPpVQ==", + "requires": { + "path-to-regexp": "^4.0.0", + "reusify": "^1.0.2" + }, + "dependencies": { + "path-to-regexp": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-4.0.5.tgz", + "integrity": "sha512-l+fTaGG2N9ZRpCEUj5fG1VKdDLaiqwCIvPngpnxzREhcdobhZC4ou4w984HBu72DqAJ5CfcdV6tjqNOunfpdsQ==" + } + } + }, "mime": { "version": "2.4.6", "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz", "integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==", "dev": true }, - "mime-db": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", - "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" - }, - "mime-types": { - "version": "2.1.27", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", - "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", - "requires": { - "mime-db": "1.44.0" - } - }, "mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -5202,8 +5101,7 @@ "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "mustache": { "version": "4.0.1", @@ -5251,11 +5149,6 @@ } } }, - "negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" - }, "node-fetch": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", @@ -5503,14 +5396,6 @@ "symbol-observable": "^1.0.4" } }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "requires": { - "ee-first": "1.1.1" - } - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -5731,11 +5616,6 @@ "integrity": "sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA==", "dev": true }, - "parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" - }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -5766,11 +5646,6 @@ "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, - "path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" - }, "path-type": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", @@ -5807,6 +5682,24 @@ "pinkie": "^2.0.0" } }, + "pino": { + "version": "5.17.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-5.17.0.tgz", + "integrity": "sha512-LqrqmRcJz8etUjyV0ddqB6OTUutCgQULPFg2b4dtijRHUsucaAdBgSUW58vY6RFSX+NT8963F+q0tM6lNwGShA==", + "requires": { + "fast-redact": "^2.0.0", + "fast-safe-stringify": "^2.0.7", + "flatstr": "^1.0.12", + "pino-std-serializers": "^2.4.2", + "quick-format-unescaped": "^3.0.3", + "sonic-boom": "^0.7.5" + } + }, + "pino-std-serializers": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-2.4.2.tgz", + "integrity": "sha512-WaL504dO8eGs+vrK+j4BuQQq6GLKeCCcHaMB2ItygzVURcL1CycwNEUHTD/lHFHs/NL5qAz2UKrjYWXKSf4aMQ==" + }, "pkg-conf": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/pkg-conf/-/pkg-conf-3.1.0.tgz", @@ -6037,8 +5930,7 @@ "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "pupa": { "version": "2.0.1", @@ -6052,8 +5944,12 @@ "qs": { "version": "6.9.4", "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", - "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==", - "dev": true + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==" + }, + "quick-format-unescaped": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-3.0.3.tgz", + "integrity": "sha512-dy1yjycmn9blucmJLXOfZDx1ikZJUi6E8bBZLnhPG5gBrVhHXx2xVyqqgKBubVNEXmx51dBACMHpoMQK/N/AXQ==" }, "quick-lru": { "version": "1.1.0", @@ -6061,22 +5957,6 @@ "integrity": "sha1-Q2CxfGETatOAeDl/8RQW4Ybc+7g=", "dev": true }, - "range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" - }, - "raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", - "requires": { - "bytes": "3.1.0", - "http-errors": "1.7.2", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - } - }, "rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", @@ -6326,6 +6206,11 @@ "signal-exit": "^3.0.2" } }, + "ret": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.2.2.tgz", + "integrity": "sha512-M0b3YWQs7R3Z917WRQy1HHA7Ba7D8hvZg6UE5mLykJxQVE2ju0IXbGlaHPPlkY+WN7wFP+wUMXmBFA0aV6vYGQ==" + }, "retry-axios": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/retry-axios/-/retry-axios-0.3.2.tgz", @@ -6335,8 +6220,12 @@ "reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" + }, + "rfdc": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz", + "integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug==" }, "rimraf": { "version": "2.6.3", @@ -6374,10 +6263,19 @@ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "dev": true }, + "safe-regex2": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/safe-regex2/-/safe-regex2-2.0.0.tgz", + "integrity": "sha512-PaUSFsUaNNuKwkBijoAPHAK6/eM6VirvyPWlZ7BAQy4D+hCvh4B6lIG+nPdhbFfIbP+gTGBcrdsOaUs0F+ZBOQ==", + "requires": { + "ret": "~0.2.0" + } + }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true }, "sax": { "version": "1.2.4", @@ -6385,11 +6283,15 @@ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "dev": true }, + "secure-json-parse": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.1.0.tgz", + "integrity": "sha512-GckO+MS/wT4UogDyoI/H/S1L0MCcKS1XX/vp48wfmU7Nw4woBmb8mIpu4zPBQjKlRT88/bt9xdoV4111jPpNJA==" + }, "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" }, "semver-diff": { "version": "3.1.1", @@ -6400,52 +6302,10 @@ "semver": "^6.3.0" } }, - "send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", - "requires": { - "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "~1.7.2", - "mime": "1.6.0", - "ms": "2.1.1", - "on-finished": "~2.3.0", - "range-parser": "~1.2.1", - "statuses": "~1.5.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - }, - "dependencies": { - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - } - } - }, - "mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" - }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" - } - } + "semver-store": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/semver-store/-/semver-store-0.3.0.tgz", + "integrity": "sha512-TcZvGMMy9vodEFSse30lWinkj+JgOBvPn8wRItpQRSayhc+4ssDs335uklkfvQQJgL/WvmHLVj4Ycv2s7QCQMg==" }, "serialize-error": { "version": "2.1.0", @@ -6453,27 +6313,16 @@ "integrity": "sha1-ULZ51WNc34Rme9yOWa9OW4HV9go=", "dev": true }, - "serve-static": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", - "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", - "requires": { - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.17.1" - } - }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, - "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + "set-cookie-parser": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.4.6.tgz", + "integrity": "sha512-mNCnTUF0OYPwYzSHbdRdCfNNHqrne+HS5tS5xNb6yJbdP9wInV0q5xPLE0EyfV/Q3tImo3y/OXpD8Jn0Jtnjrg==" }, "shebang-command": { "version": "2.0.0", @@ -6521,6 +6370,15 @@ } } }, + "sonic-boom": { + "version": "0.7.7", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-0.7.7.tgz", + "integrity": "sha512-Ei5YOo5J64GKClHIL/5evJPgASXFVpfVYbJV9PILZQytTK6/LCwHvsZJW2Ig4p9FMC2OrBrMnXKgRN/OEoAWfg==", + "requires": { + "atomic-sleep": "^1.0.0", + "flatstr": "^1.0.12" + } + }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -6589,10 +6447,10 @@ "integrity": "sha512-MTX+MeG5U994cazkjd/9KNAapsHnibjMLnfXodlkXw76JEea0UiNzrqidzo1emMwk7w5Qhc9jd4Bn9TBb1MFwA==", "dev": true }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + "string-similarity": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.1.tgz", + "integrity": "sha512-v36MJzloekKVvKAsYi6O/qpn2mIuvwEFIT9Gx3yg4spkNjXYsk7yxc37g4ZTyMVIBvt/9PZGxnqEtme8XHK+Mw==" }, "string-width": { "version": "4.2.0", @@ -6662,7 +6520,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, "requires": { "safe-buffer": "~5.1.0" }, @@ -6670,8 +6527,7 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" } } }, @@ -6866,6 +6722,11 @@ "integrity": "sha1-mcW/VZWJZq9tBtg73zgA3IL67F0=", "dev": true }, + "tiny-lru": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/tiny-lru/-/tiny-lru-7.0.6.tgz", + "integrity": "sha512-zNYO0Kvgn5rXzWpL0y3RS09sMK67eGaQj9805jlK9G6pSadfriTczzLHFXa/xcW4mIRfmlB9HyQ/+SgL0V1uow==" + }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -6896,11 +6757,6 @@ "is-number": "^7.0.0" } }, - "toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" - }, "touch": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", @@ -6970,15 +6826,6 @@ "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", "dev": true }, - "type-is": { - "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "requires": { - "media-typer": "0.3.0", - "mime-types": "~2.1.24" - } - }, "typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", @@ -7074,11 +6921,6 @@ "uid2": "0.0.3" } }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" - }, "update-notifier": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-4.1.0.tgz", @@ -7156,7 +6998,6 @@ "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "dev": true, "requires": { "punycode": "^2.1.0" } @@ -7179,13 +7020,7 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { "version": "3.4.0", @@ -7209,11 +7044,6 @@ "spdx-expression-parse": "^3.0.0" } }, - "vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" - }, "walkdir": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/walkdir/-/walkdir-0.4.1.tgz", diff --git a/package.json b/package.json index 281d94f..3e56a3b 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "actions-on-google": "^2.12.0" }, "dependencies": { - "body-parser": "^1.19.0", - "express": "^4.17.1" + "fastify": "^2.14.1", + "fastify-formbody": "^3.2.0" }, "devDependencies": { "@k-foss/ts-esnode": "1.6.0", diff --git a/src/Lab/Auth.ts b/src/Lab/Auth.ts deleted file mode 100644 index 041e2c0..0000000 --- a/src/Lab/Auth.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* eslint-disable camelcase */ -import * as express from 'express'; -import * as util from 'util'; - -/** - * A function that adds /login, /fakeauth, /faketoken endpoints to an - * Express server. Replace this with your own OAuth endpoints. - * - * @param expressApp Express app - */ -export async function registerAuthEndpoints( - expressApp: express.Express, -): Promise { - expressApp.get( - '/login', - (req, res) => { - res.send(` - - -
- - -
- - - `); - }, - ); - - expressApp.post< - any, - any, - { - responseurl: string; - } - >('/login', async (req, res) => { - // Here, you should validate the user account. - // In this sample, we do not do that. - const responseurl = decodeURIComponent(req.body.responseurl); - console.log(`Redirect to ${responseurl}, ${JSON.stringify(req.body)}`); - return res.redirect(responseurl); - }); - - expressApp.get( - '/fakeauth', - async (req, res) => { - const responseurl = util.format( - '%s?code=%s&state=%s', - decodeURIComponent(req.query.redirect_uri), - 'xxxxxx', - req.query.state, - ); - console.log(`Set redirect as ${responseurl}`); - return res.redirect( - `/login?responseurl=${encodeURIComponent(responseurl)}`, - ); - }, - ); - - expressApp.all( - '/faketoken', - async (req, res) => { - const grantType = req.query.grant_type - ? req.query.grant_type - : req.body.grant_type; - - const secondsInDay = 86400; // 60 * 60 * 24 - const HTTP_STATUS_OK = 200; - - let obj; - if (grantType === 'authorization_code') { - obj = { - token_type: 'bearer', - access_token: '123access', - refresh_token: '123refresh', - expires_in: secondsInDay, - }; - } else if (grantType === 'refresh_token') { - obj = { - token_type: 'bearer', - access_token: '123access', - expires_in: secondsInDay, - }; - } - - res.status(HTTP_STATUS_OK).json(obj); - }, - ); -} diff --git a/src/Lab/Library/Fastify.ts b/src/Lab/Library/Fastify.ts new file mode 100644 index 0000000..e583456 --- /dev/null +++ b/src/Lab/Library/Fastify.ts @@ -0,0 +1,103 @@ +// Lab/Library/Fastify.ts +import fastify, { + FastifyInstance, + RequestHandler, + RouteOptions, + DefaultBody, + DefaultHeaders, + DefaultParams, + DefaultQuery, +} from 'fastify'; +import fastifyFormBody from 'fastify-formbody'; +import { findModuleFiles } from '../Utils/moduleFileFinder'; +import { IncomingMessage, ServerResponse } from 'http'; + +/** + * Fastify Route + */ +export abstract class Route< + Body = DefaultBody, + Query = DefaultQuery, + HttpRequest = IncomingMessage, + HttpResponse = ServerResponse, + Params = DefaultParams, + Headers = DefaultHeaders +> { + /** + * Fastify Route Options + * https://www.fastify.io/docs/latest/Routes/#routes-option + */ + public options: Omit; + + /** + * Fastify Route Handler + */ + abstract handler: RequestHandler< + HttpRequest, + HttpResponse, + Query, + Params, + Headers, + Body + >; +} + +/** + * Example route so that the findModuleFiles type isn't messed up + */ +export class ExampleRoute extends Route { + public handler: Route['handler'] = async (request, reply) => { + console.log('HelloWorld'); + + return 'example'; + }; +} + +interface RouteModule { + default: typeof ExampleRoute; +} + +export async function getRoutes(): Promise { + /** + * Get all Modules under `Modules` that match `*Route.ts` + */ + const routeModules = await findModuleFiles(/.*Route\.ts/); + + // Destructure the default export from all matching route Modules, and construct the class + return routeModules.flatMap(({ default: RouteClass }) => new RouteClass()); +} + +/** + * Create a Fastify Web Server + */ +export async function createFastifyServer(): Promise { + const webServer = fastify(); + + webServer.register(fastifyFormBody); + + /** + * Get All Route Modules. + */ + const routes = await getRoutes(); + + /** + * For each Route Module in routes destructure handler and options and register as a webServer Route. + */ + routes.map(({ handler, options }) => { + return webServer.route({ + ...options, + handler, + }); + }); + + return webServer; +} + +/** + * Creates a fastify Testing Chain https://www.fastify.io/docs/latest/Testing/ + */ +export async function createFastifyTestServer() { + const webServer = await createFastifyServer(); + + return webServer; +} diff --git a/src/Lab/Modules/Auth/AuthRoute.ts b/src/Lab/Modules/Auth/AuthRoute.ts new file mode 100644 index 0000000..2de417b --- /dev/null +++ b/src/Lab/Modules/Auth/AuthRoute.ts @@ -0,0 +1,26 @@ +// Lab/Modules/Auth/AuthRoute.ts +import { Route } from '../../Library/Fastify'; +import * as util from 'util'; + +/** + * Example route so that the findModuleFiles type isn't messed up + */ +export default class AuthRoute extends Route { + public options: Route['options'] = { + method: 'GET', + url: '/auth', + }; + + public handler: Route['handler'] = async (request, reply) => { + const responseurl = util.format( + '%s?code=%s&state=%s', + decodeURIComponent(request.query.redirect_uri), + 'xxxxxx', + request.query.state, + ); + console.log(`Set redirect as ${responseurl}`); + return reply.redirect( + `/login?responseurl=${encodeURIComponent(responseurl)}`, + ); + }; +} diff --git a/src/Lab/Modules/Auth/LoginPageRoute.ts b/src/Lab/Modules/Auth/LoginPageRoute.ts new file mode 100644 index 0000000..75ff78e --- /dev/null +++ b/src/Lab/Modules/Auth/LoginPageRoute.ts @@ -0,0 +1,44 @@ +// Lab/Modules/Auth/AuthRoute.ts +import { Route } from '../../Library/Fastify'; + +/** + * Example route so that the findModuleFiles type isn't messed up + */ +export default class LoginPageRoute extends Route< + any, + { responseurl: string } +> { + public options: Route['options'] = { + method: 'GET', + url: '/login', + schema: { + querystring: { + type: 'object', + required: ['responseurl'], + properties: { + name: { type: 'string' }, + }, + }, + }, + }; + + public handler: Route['handler'] = async ( + request, + reply, + ) => { + const responseUrl = request.query.responseurl; + + console.debug(`loginPage:`, request, reply); + + reply.type('text/html'); + + return ` + +
+ + +
+ + `; + }; +} diff --git a/src/Lab/Modules/Auth/LoginRoute.ts b/src/Lab/Modules/Auth/LoginRoute.ts new file mode 100644 index 0000000..a4b75f2 --- /dev/null +++ b/src/Lab/Modules/Auth/LoginRoute.ts @@ -0,0 +1,34 @@ +// Lab/Modules/Auth/AuthRoute.ts +import { Route } from '../../Library/Fastify'; + +/** + * Example route so that the findModuleFiles type isn't messed up + */ +export default class LoginRoute extends Route<{ responseurl: string }> { + public options: Route['options'] = { + method: 'POST', + url: '/login', + schema: { + body: { + type: 'object', + required: ['responseurl'], + properties: { + responseurl: { type: 'string' }, + }, + }, + }, + }; + + public handler: Route<{ responseurl: string }>['handler'] = async ( + request, + reply, + ) => { + // Here, you should validate the user account. + // In this sample, we do not do that. + const responseurl = decodeURIComponent(request.body.responseurl); + + console.log(request, reply); + + reply.redirect(responseurl); + }; +} diff --git a/src/Lab/Modules/Auth/TokenRoute.ts b/src/Lab/Modules/Auth/TokenRoute.ts new file mode 100644 index 0000000..71181f8 --- /dev/null +++ b/src/Lab/Modules/Auth/TokenRoute.ts @@ -0,0 +1,47 @@ +// Lab/Modules/Auth/TokenRoute.ts +import { Route } from '../../Library/Fastify'; + +/** + * Example route so that the findModuleFiles type isn't messed up + */ +export default class LoginPageRoute extends Route< + { grant_type: string }, + { grant_type: string } +> { + public options: Route['options'] = { + method: 'POST', + url: '/token', + }; + + public handler: Route< + { grant_type: string }, + { grant_type: string } + >['handler'] = async (request, reply) => { + console.log('token'); + + const grantType = request.query.grant_type + ? request.query.grant_type + : request.body.grant_type; + + const secondsInDay = 86400; // 60 * 60 * 24 + const HTTP_STATUS_OK = 200; + + let obj; + if (grantType === 'authorization_code') { + obj = { + token_type: 'bearer', + access_token: '123access', + refresh_token: '123refresh', + expires_in: secondsInDay, + }; + } else if (grantType === 'refresh_token') { + obj = { + token_type: 'bearer', + access_token: '123access', + expires_in: secondsInDay, + }; + } + + reply.status(200).type('application/json').send(obj); + }; +} diff --git a/src/Lab/Utils/moduleFileFinder.ts b/src/Lab/Utils/moduleFileFinder.ts new file mode 100644 index 0000000..3d0d488 --- /dev/null +++ b/src/Lab/Utils/moduleFileFinder.ts @@ -0,0 +1,43 @@ +// Lab/Utils/moduleFileFinder.ts +import { promises as fs } from 'fs'; +import { resolvePath } from './resolvePath'; +import { resolve } from 'path'; +import { pathToFileURL } from 'url'; + +type FileMatcher = RegExp; + +const coreModulesDir = resolvePath('../Modules', import.meta.url); + +/** + * Finds module files that match the fileMatcher + * @param + */ +export async function findModuleFiles( + fileMatcher: FileMatcher, + rootDir: string = coreModulesDir, +): Promise { + async function processDirectory(directoryPath: string): Promise { + const directoryContents = await fs.readdir(directoryPath, { + encoding: 'utf-8', + withFileTypes: true, + }); + + return Promise.all( + directoryContents.flatMap((directoryContent) => { + const contentPath = resolve(directoryPath, directoryContent.name); + + if (directoryContent.isDirectory()) { + return processDirectory(contentPath); + } + + if (fileMatcher.test(directoryContent.name) === true) { + return import(pathToFileURL(contentPath).href) as Promise; + } + + return []; + }), + ); + } + + return (await processDirectory(rootDir)).flat(500); +} diff --git a/src/Lab/Utils/resolvePath.ts b/src/Lab/Utils/resolvePath.ts new file mode 100644 index 0000000..332ba15 --- /dev/null +++ b/src/Lab/Utils/resolvePath.ts @@ -0,0 +1,12 @@ +// Lab/Utils/resolvePath.ts +import { resolve } from 'path'; +import { fileURLToPath } from 'url'; + +/** + * Resolve the full path of a path + * @param path Source file path + * @param parentUrl Parent URL + */ +export function resolvePath(path: string, parentUrl: string): string { + return resolve(fileURLToPath(parentUrl), `../${path}`); +} diff --git a/src/Lab/index.ts b/src/Lab/index.ts index 4266dd5..baa6e7f 100644 --- a/src/Lab/index.ts +++ b/src/Lab/index.ts @@ -1,9 +1,7 @@ // src/Lab/index.ts +import { createFastifyServer } from './Library/Fastify'; import { SmartHomeController } from '../Modules/SmartHome'; import { CoreLight } from './Devices/CoreLight'; -import express from 'express'; -import bodyParser from 'body-parser'; -import { registerAuthEndpoints } from './Auth'; import { Jumper } from './Devices/Jumper'; if (process.env.NODE_ENV !== 'production') { @@ -12,16 +10,25 @@ if (process.env.NODE_ENV !== 'production') { config(); } -const webServer = express(); -webServer.use(bodyParser.json()); -webServer.use(bodyParser.urlencoded({ extended: true })); +const webServer = await createFastifyServer(); const smartHomeController = await SmartHomeController.createController({ devices: [new CoreLight(), new Jumper()], }); -webServer.post('/fulfillment', smartHomeController.smartHome); +webServer.all('/fulfillment*', async (request, reply) => { + const smartHomeReply = await smartHomeController.smartHome.handler( + request.body, + request.headers, + ); -await registerAuthEndpoints(webServer); + reply.status(smartHomeReply.status); -webServer.listen(3000); + if (smartHomeReply.headers) { + reply.headers(smartHomeReply.headers); + } + + return smartHomeReply.body; +}); + +await webServer.listen(3000, '0.0.0.0'); diff --git a/src/Modules/Controller/Controller.ts b/src/Modules/Controller/Controller.ts deleted file mode 100644 index fa260d0..0000000 --- a/src/Modules/Controller/Controller.ts +++ /dev/null @@ -1,3 +0,0 @@ -// src/Modules/Controller/Controller.ts - -export class Controller {} diff --git a/src/Modules/Controller/index.ts b/src/Modules/Controller/index.ts deleted file mode 100644 index 27a0dac..0000000 --- a/src/Modules/Controller/index.ts +++ /dev/null @@ -1 +0,0 @@ -// src/Modules/Controller/index.ts diff --git a/src/Modules/SmartHome/SmartHomeController.ts b/src/Modules/SmartHome/SmartHomeController.ts index 4f81d09..693c44c 100644 --- a/src/Modules/SmartHome/SmartHomeController.ts +++ b/src/Modules/SmartHome/SmartHomeController.ts @@ -45,6 +45,7 @@ export class SmartHomeController< const smartHome = smarthome({ key: process.env.KEY, jwt, + debug: true, }); const smartHomeController = new SmartHomeController(); @@ -75,6 +76,34 @@ export class SmartHomeController< return smartHomeController; } + public async getDeviceStatus( + deviceIds?: string[], + ): Promise<[string, unknown][]> { + let devices: SmartHomeController['devices']; + + if (deviceIds) { + devices = deviceIds.flatMap((deviceId) => { + const localDevice = this.devices.find( + (device) => device.id === deviceId, + ); + if (!localDevice) { + return []; + } + + return localDevice; + }); + } else { + devices = this.devices; + } + + return Promise.all( + devices.map>(async (localDevice) => [ + localDevice.id, + await localDevice.getStatus(), + ]), + ); + } + public async onExecute( body: SmartHomeV1ExecuteRequest, headers: Headers, @@ -137,34 +166,6 @@ export class SmartHomeController< }; } - public async getDeviceStatus( - deviceIds?: string[], - ): Promise<[string, unknown][]> { - let devices: BaseDevice>[]; - - if (deviceIds) { - devices = deviceIds.flatMap((deviceId) => { - const localDevice = this.devices.find( - (device) => device.id === deviceId, - ); - if (!localDevice) { - return []; - } - - return localDevice; - }); - } else { - devices = this.devices; - } - - return Promise.all( - devices.map>(async (localDevice) => [ - localDevice.id, - await localDevice.getStatus(), - ]), - ); - } - public async onQuery( body: SmartHomeV1QueryRequest, headers: Headers,