diff --git a/package-lock.json b/package-lock.json index 1c56c07..0c7b89d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "zano-explorer", "version": "0.1.0", + "hasInstallScript": true, "dependencies": { "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", @@ -16,8 +17,7 @@ "@types/node": "^16.18.57", "@types/react": "^18.2.25", "@types/react-dom": "^18.2.10", - "dotenv": "^16.4.5", - "express": "^4.18.2", + "concurrently": "^8.2.2", "highcharts": "^11.1.0", "highcharts-react-official": "^3.2.1", "http-proxy-middleware": "^2.0.6", @@ -28,8 +28,7 @@ "react-router-dom": "^6.16.0", "react-scripts": "5.0.1", "sass": "^1.68.0", - "sequelize": "^6.37.3", - "socket.io-client": "^4.7.2", + "socket.io-client": "^4.7.5", "typescript": "^4.9.5", "web-vitals": "^2.1.4" }, @@ -3376,9 +3375,9 @@ } }, "node_modules/@socket.io/component-emitter": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", - "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz", + "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==" }, "node_modules/@surma/rollup-plugin-off-main-thread": { "version": "2.2.3", @@ -3992,14 +3991,6 @@ "@types/node": "*" } }, - "node_modules/@types/debug": { - "version": "4.1.12", - "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", - "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", - "dependencies": { - "@types/ms": "*" - } - }, "node_modules/@types/eslint": { "version": "8.44.3", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.44.3.tgz", @@ -4116,11 +4107,6 @@ "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.3.tgz", "integrity": "sha512-Ys+/St+2VF4+xuY6+kDIXGxbNRO0mesVg0bbxEfB97Od1Vjpjx9KD1qxs64Gcb3CWPirk9Xe+PT4YiiHQ9T+eg==" }, - "node_modules/@types/ms": { - "version": "0.7.34", - "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", - "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" - }, "node_modules/@types/nanoid": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/nanoid/-/nanoid-3.0.0.tgz", @@ -4259,11 +4245,6 @@ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.4.tgz", "integrity": "sha512-IDaobHimLQhjwsQ/NMwRVfa/yL7L/wriQPMhw1ZJall0KX6E1oxk29XMDeilW5qTIg5aoiqf5Udy8U/51aNoQQ==" }, - "node_modules/@types/validator": { - "version": "13.12.0", - "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.12.0.tgz", - "integrity": "sha512-nH45Lk7oPIJ1RVOF6JgFI6Dy0QpHEzq4QecZhvguxYPDwT8c93prCMqAtiIttm39voZ+DDR+qkNnMpJmMBRqag==" - }, "node_modules/@types/ws": { "version": "8.5.6", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.6.tgz", @@ -5465,12 +5446,12 @@ "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, "node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dependencies": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -5478,7 +5459,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -5966,6 +5947,148 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, + "node_modules/concurrently": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.2.2.tgz", + "integrity": "sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==", + "dependencies": { + "chalk": "^4.1.2", + "date-fns": "^2.30.0", + "lodash": "^4.17.21", + "rxjs": "^7.8.1", + "shell-quote": "^1.8.1", + "spawn-command": "0.0.2", + "supports-color": "^8.1.1", + "tree-kill": "^1.2.2", + "yargs": "^17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": "^14.13.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/concurrently/node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/concurrently/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/concurrently/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/concurrently/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/concurrently/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/concurrently/node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "engines": { + "node": ">=12" + } + }, "node_modules/confusing-browser-globals": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz", @@ -6004,9 +6127,9 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } @@ -6502,6 +6625,21 @@ "node": ">=10" } }, + "node_modules/date-fns": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", + "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -6840,27 +6978,11 @@ "tslib": "^2.0.3" } }, - "node_modules/dotenv": { - "version": "16.4.5", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", - "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, "node_modules/dotenv-expand": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz", "integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==" }, - "node_modules/dottie": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.6.tgz", - "integrity": "sha512-iGCHkfUc5kFekGiqhe8B/mdaurD+lakO9txNnTvKtA6PISrw86LgqHvRzWYPyoE2Ph5aMIrCw9/uko6XHTKCwA==" - }, "node_modules/duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", @@ -6923,27 +7045,27 @@ } }, "node_modules/engine.io-client": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz", - "integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.4.tgz", + "integrity": "sha512-GeZeeRjpD2qf49cZQ0Wvh/8NJNfeXkXXcoGh+F77oEAgo9gUHwT1fCRxSNU+YEEaysOJTnsFHmM5oAcPy4ntvQ==", "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1", "engine.io-parser": "~5.2.1", - "ws": "~8.11.0", + "ws": "~8.17.1", "xmlhttprequest-ssl": "~2.0.0" } }, "node_modules/engine.io-client/node_modules/ws": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", - "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "engines": { "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { @@ -6955,9 +7077,9 @@ } }, "node_modules/engine.io-parser": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.1.tgz", - "integrity": "sha512-9JktcM3u18nU9N2Lz3bWeBgxVgOKpw7yhRaoxQA3FUDZzzw+9WlA6p4G4u0RixNkg14fH7EfEc/RhpurtiROTQ==", + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz", + "integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==", "engines": { "node": ">=10.0.0" } @@ -7919,16 +8041,16 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -9167,14 +9289,6 @@ "node": ">=8" } }, - "node_modules/inflection": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.13.4.tgz", - "integrity": "sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw==", - "engines": [ - "node >= 0.4.0" - ] - }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -12334,25 +12448,6 @@ "mkdirp": "bin/cmd.js" } }, - "node_modules/moment": { - "version": "2.30.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", - "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", - "engines": { - "node": "*" - } - }, - "node_modules/moment-timezone": { - "version": "0.5.45", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.45.tgz", - "integrity": "sha512-HIWmqA86KcmCAhnMAN0wuDOARV/525R2+lOLotuGFzn4HO+FH+/645z2wx0Dt3iDv6/p61SIvKnDstISainhLQ==", - "dependencies": { - "moment": "^2.29.4" - }, - "engines": { - "node": "*" - } - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -12935,11 +13030,6 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" }, - "node_modules/pg-connection-string": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.6.4.tgz", - "integrity": "sha512-v+Z7W/0EO707aNMaAEfiGnGL9sxxumwLl2fJvCQtMn9Fxsg+lPpPkdcyBSv/KFgpGdYkMfn+EI1Or2EHjpgLCA==" - }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -14497,9 +14587,9 @@ } }, "node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -15141,11 +15231,6 @@ "node": ">= 4" } }, - "node_modules/retry-as-promised": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-7.0.4.tgz", - "integrity": "sha512-XgmCoxKWkDofwH8WddD0w85ZfqYz+ZHlr5yo+3YUCfycWawU56T5ckWXsScsj5B8tqUcIG67DxXByo3VUgiAdA==" - }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -15260,6 +15345,14 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dependencies": { + "tslib": "^2.1.0" + } + }, "node_modules/safe-array-concat": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.0.1.tgz", @@ -15500,75 +15593,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, - "node_modules/sequelize": { - "version": "6.37.3", - "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.37.3.tgz", - "integrity": "sha512-V2FTqYpdZjPy3VQrZvjTPnOoLm0KudCRXfGWp48QwhyPPp2yW8z0p0sCYZd/em847Tl2dVxJJ1DR+hF+O77T7A==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/sequelize" - } - ], - "dependencies": { - "@types/debug": "^4.1.8", - "@types/validator": "^13.7.17", - "debug": "^4.3.4", - "dottie": "^2.0.6", - "inflection": "^1.13.4", - "lodash": "^4.17.21", - "moment": "^2.29.4", - "moment-timezone": "^0.5.43", - "pg-connection-string": "^2.6.1", - "retry-as-promised": "^7.0.4", - "semver": "^7.5.4", - "sequelize-pool": "^7.1.0", - "toposort-class": "^1.0.1", - "uuid": "^8.3.2", - "validator": "^13.9.0", - "wkx": "^0.5.0" - }, - "engines": { - "node": ">=10.0.0" - }, - "peerDependenciesMeta": { - "ibm_db": { - "optional": true - }, - "mariadb": { - "optional": true - }, - "mysql2": { - "optional": true - }, - "oracledb": { - "optional": true - }, - "pg": { - "optional": true - }, - "pg-hstore": { - "optional": true - }, - "snowflake-sdk": { - "optional": true - }, - "sqlite3": { - "optional": true - }, - "tedious": { - "optional": true - } - } - }, - "node_modules/sequelize-pool": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/sequelize-pool/-/sequelize-pool-7.1.0.tgz", - "integrity": "sha512-G9c0qlIWQSK29pR/5U2JF5dDQeqqHRragoyahj/Nx4KOOQ3CPPfzxnfqFPCSB7x5UgjOgnZ61nSxz+fjDpRlJg==", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/serialize-javascript": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", @@ -15750,9 +15774,9 @@ } }, "node_modules/socket.io-client": { - "version": "4.7.2", - "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.2.tgz", - "integrity": "sha512-vtA0uD4ibrYD793SOIAwlo8cj6haOeMHrGvwPxJsxH7CeIksqJ+3Zc06RvWTIFgiSqx4A3sOnTXpfAEE2Zyz6w==", + "version": "4.7.5", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.5.tgz", + "integrity": "sha512-sJ/tqHOCe7Z50JCBCXrsY3I2k03iOiUe+tj1OmKeD2lXPiGH/RUCdTZFoqVyN7l1MnpIzPrGtLcijffmeouNlQ==", "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.2", @@ -15849,6 +15873,11 @@ "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", "deprecated": "Please use @jridgewell/sourcemap-codec instead" }, + "node_modules/spawn-command": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", + "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==" + }, "node_modules/spdy": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/spdy/-/spdy-4.0.2.tgz", @@ -16648,11 +16677,6 @@ "node": ">=0.6" } }, - "node_modules/toposort-class": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toposort-class/-/toposort-class-1.0.1.tgz", - "integrity": "sha512-OsLcGGbYF3rMjPUf8oKktyvCiUxSbqMMS39m33MAjLTC1DVIH6x3WSt63/M77ihI09+Sdfk1AXvfhCEeUmC7mg==" - }, "node_modules/touch": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", @@ -16698,6 +16722,14 @@ "node": ">=8" } }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "bin": { + "tree-kill": "cli.js" + } + }, "node_modules/tryer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz", @@ -17091,14 +17123,6 @@ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" }, - "node_modules/validator": { - "version": "13.12.0", - "resolved": "https://registry.npmjs.org/validator/-/validator-13.12.0.tgz", - "integrity": "sha512-c1Q0mCiPlgdTVVVIJIrBuxNicYE+t/7oKeI9MWLj3fh/uq2Pxh/3eeWbVZ4OcGW1TUf53At0njHw5SMdA3tmMg==", - "engines": { - "node": ">= 0.10" - } - }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -17624,14 +17648,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/wkx": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/wkx/-/wkx-0.5.0.tgz", - "integrity": "sha512-Xng/d4Ichh8uN4l0FToV/258EjMGU9MGcA0HV2d9B/ZpZB3lqQm7nkOdZdm5GhKtLLhAE7PiVQwN4eN+2YJJUg==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", diff --git a/package.json b/package.json index 594b6ee..5abf1b4 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,7 @@ "@types/node": "^16.18.57", "@types/react": "^18.2.25", "@types/react-dom": "^18.2.10", - "dotenv": "^16.4.5", - "express": "^4.18.2", + "concurrently": "^8.2.2", "highcharts": "^11.1.0", "highcharts-react-official": "^3.2.1", "http-proxy-middleware": "^2.0.6", @@ -23,18 +22,17 @@ "react-router-dom": "^6.16.0", "react-scripts": "5.0.1", "sass": "^1.68.0", - "sequelize": "^6.37.3", - "socket.io-client": "^4.7.2", + "socket.io-client": "^4.7.5", "typescript": "^4.9.5", "web-vitals": "^2.1.4" }, "scripts": { + "postinstall": "cd server && npm i", "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", - "server-dev": "npx nodemon ./api/server.ts", - "server": "npx ts-node ./api/server.ts" + "dev": "concurrently \"npx nodemon --exec tsx ./server/server.ts\" \"npm start\"" }, "eslintConfig": { "extends": [ diff --git a/server/exceptionHandler.ts b/server/exceptionHandler.ts index 3705210..e7e3eaa 100644 --- a/server/exceptionHandler.ts +++ b/server/exceptionHandler.ts @@ -2,7 +2,9 @@ import { Request, Response, NextFunction } from 'express'; const exceptionHandler = (fn: (req: Request, res: Response, next: NextFunction) => any) => (req: Request, res: Response, next: NextFunction) => { - Promise.resolve(fn(req, res, next)).catch(next); + Promise.resolve(fn(req, res, next)).catch((e) => { + next(); + }); }; export default exceptionHandler; diff --git a/server/package-lock.json b/server/package-lock.json index 0e9bf07..b1d129f 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -12,10 +12,12 @@ "axios": "^1.5.1", "bignumber.js": "^9.1.2", "concurrently": "^8.2.2", - "express": "^4.18.2", + "dotenv": "^16.4.5", + "express": "^4.19.2", "node-fetch": "^2.6.5", "nodemon": "^3.0.1", "pg": "^8.11.3", + "sequelize": "^6.37.3", "socket.io": "^4.7.2" } }, @@ -48,6 +50,19 @@ "@types/node": "*" } }, + "node_modules/@types/debug": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", + "dependencies": { + "@types/ms": "*" + } + }, + "node_modules/@types/ms": { + "version": "0.7.34", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", + "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" + }, "node_modules/@types/node": { "version": "20.8.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.8.tgz", @@ -56,6 +71,11 @@ "undici-types": "~5.25.1" } }, + "node_modules/@types/validator": { + "version": "13.12.1", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.12.1.tgz", + "integrity": "sha512-w0URwf7BQb0rD/EuiG12KP0bailHKHP5YVviJG9zw3ykAokL0TuxU2TUqMB7EwZ59bDHYdeTIvjI5m0S7qHfOA==" + }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -157,12 +177,12 @@ } }, "node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dependencies": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -170,7 +190,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -216,13 +236,18 @@ } }, "node_modules/call-bind": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", - "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.1", - "set-function-length": "^1.1.1" + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -371,9 +396,9 @@ } }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } @@ -419,16 +444,19 @@ } }, "node_modules/define-data-property": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", - "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dependencies": { - "get-intrinsic": "^1.2.1", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" }, "engines": { "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/delayed-stream": { @@ -456,6 +484,22 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dottie": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.6.tgz", + "integrity": "sha512-iGCHkfUc5kFekGiqhe8B/mdaurD+lakO9txNnTvKtA6PISrw86LgqHvRzWYPyoE2Ph5aMIrCw9/uko6XHTKCwA==" + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -531,6 +575,25 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -553,16 +616,16 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -699,15 +762,19 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", - "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dependencies": { + "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -743,20 +810,20 @@ } }, "node_modules/has-property-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", - "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dependencies": { - "get-intrinsic": "^1.2.2" + "es-define-property": "^1.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/has-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", - "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", "engines": { "node": ">= 0.4" }, @@ -776,9 +843,9 @@ } }, "node_modules/hasown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", - "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", "dependencies": { "function-bind": "^1.1.2" }, @@ -817,6 +884,14 @@ "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" }, + "node_modules/inflection": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.13.4.tgz", + "integrity": "sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw==", + "engines": [ + "node >= 0.4.0" + ] + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -954,6 +1029,25 @@ "node": "*" } }, + "node_modules/moment": { + "version": "2.30.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", + "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", + "engines": { + "node": "*" + } + }, + "node_modules/moment-timezone": { + "version": "0.5.45", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.45.tgz", + "integrity": "sha512-HIWmqA86KcmCAhnMAN0wuDOARV/525R2+lOLotuGFzn4HO+FH+/645z2wx0Dt3iDv6/p61SIvKnDstISainhLQ==", + "dependencies": { + "moment": "^2.29.4" + }, + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -1068,9 +1162,12 @@ } }, "node_modules/object-inspect": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", - "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", + "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -1278,9 +1375,9 @@ } }, "node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -1315,6 +1412,11 @@ "node": ">=0.10.0" } }, + "node_modules/retry-as-promised": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-7.0.4.tgz", + "integrity": "sha512-XgmCoxKWkDofwH8WddD0w85ZfqYz+ZHlr5yo+3YUCfycWawU56T5ckWXsScsj5B8tqUcIG67DxXByo3VUgiAdA==" + }, "node_modules/rxjs": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", @@ -1389,6 +1491,96 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, + "node_modules/sequelize": { + "version": "6.37.3", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.37.3.tgz", + "integrity": "sha512-V2FTqYpdZjPy3VQrZvjTPnOoLm0KudCRXfGWp48QwhyPPp2yW8z0p0sCYZd/em847Tl2dVxJJ1DR+hF+O77T7A==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/sequelize" + } + ], + "dependencies": { + "@types/debug": "^4.1.8", + "@types/validator": "^13.7.17", + "debug": "^4.3.4", + "dottie": "^2.0.6", + "inflection": "^1.13.4", + "lodash": "^4.17.21", + "moment": "^2.29.4", + "moment-timezone": "^0.5.43", + "pg-connection-string": "^2.6.1", + "retry-as-promised": "^7.0.4", + "semver": "^7.5.4", + "sequelize-pool": "^7.1.0", + "toposort-class": "^1.0.1", + "uuid": "^8.3.2", + "validator": "^13.9.0", + "wkx": "^0.5.0" + }, + "engines": { + "node": ">=10.0.0" + }, + "peerDependenciesMeta": { + "ibm_db": { + "optional": true + }, + "mariadb": { + "optional": true + }, + "mysql2": { + "optional": true + }, + "oracledb": { + "optional": true + }, + "pg": { + "optional": true + }, + "pg-hstore": { + "optional": true + }, + "snowflake-sdk": { + "optional": true + }, + "sqlite3": { + "optional": true + }, + "tedious": { + "optional": true + } + } + }, + "node_modules/sequelize-pool": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/sequelize-pool/-/sequelize-pool-7.1.0.tgz", + "integrity": "sha512-G9c0qlIWQSK29pR/5U2JF5dDQeqqHRragoyahj/Nx4KOOQ3CPPfzxnfqFPCSB7x5UgjOgnZ61nSxz+fjDpRlJg==", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/sequelize/node_modules/debug": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", + "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/sequelize/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "node_modules/serve-static": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", @@ -1404,14 +1596,16 @@ } }, "node_modules/set-function-length": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", - "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", "dependencies": { - "define-data-property": "^1.1.1", - "get-intrinsic": "^1.2.1", + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "has-property-descriptors": "^1.0.2" }, "engines": { "node": ">= 0.4" @@ -1431,13 +1625,17 @@ } }, "node_modules/side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", + "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", "dependencies": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" + "call-bind": "^1.0.7", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -1611,6 +1809,11 @@ "node": ">=0.6" } }, + "node_modules/toposort-class": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toposort-class/-/toposort-class-1.0.1.tgz", + "integrity": "sha512-OsLcGGbYF3rMjPUf8oKktyvCiUxSbqMMS39m33MAjLTC1DVIH6x3WSt63/M77ihI09+Sdfk1AXvfhCEeUmC7mg==" + }, "node_modules/touch": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", @@ -1678,6 +1881,22 @@ "node": ">= 0.4.0" } }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/validator": { + "version": "13.12.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-13.12.0.tgz", + "integrity": "sha512-c1Q0mCiPlgdTVVVIJIrBuxNicYE+t/7oKeI9MWLj3fh/uq2Pxh/3eeWbVZ4OcGW1TUf53At0njHw5SMdA3tmMg==", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -1700,6 +1919,14 @@ "webidl-conversions": "^3.0.0" } }, + "node_modules/wkx": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/wkx/-/wkx-0.5.0.tgz", + "integrity": "sha512-Xng/d4Ichh8uN4l0FToV/258EjMGU9MGcA0HV2d9B/ZpZB3lqQm7nkOdZdm5GhKtLLhAE7PiVQwN4eN+2YJJUg==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/server/package.json b/server/package.json index 731dcf3..615f9da 100644 --- a/server/package.json +++ b/server/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "description": "", "main": "index.js", + "type": "module", "scripts": { "wallet": "node ./dev_quick_run/windows_entry.js", "dev": "nodemon server.js", @@ -14,10 +15,12 @@ "axios": "^1.5.1", "bignumber.js": "^9.1.2", "concurrently": "^8.2.2", - "express": "^4.18.2", + "dotenv": "^16.4.5", + "express": "^4.19.2", "node-fetch": "^2.6.5", "nodemon": "^3.0.1", "pg": "^8.11.3", + "sequelize": "^6.37.3", "socket.io": "^4.7.2" } } diff --git a/server/schemes/AltBlock.ts b/server/schemes/AltBlock.ts index 21aa84e..7061dce 100644 --- a/server/schemes/AltBlock.ts +++ b/server/schemes/AltBlock.ts @@ -9,17 +9,17 @@ class AltBlock extends Model { declare size: BigInt; declare hash: string; declare type: number; - declare difficulty: number; - declare cumulative_diff_adjusted: number; + declare difficulty: string; + declare cumulative_diff_adjusted: string; declare is_orphan: boolean; - declare base_reward: number; - declare total_fee: number; + declare base_reward: string; + declare total_fee: string; declare penalty: BigInt; declare summary_reward: BigInt; - declare block_cumulative_size: number; - declare this_block_fee_median: number; - declare effective_fee_median: number; - declare total_txs_size: number; + declare block_cumulative_size: string; + declare this_block_fee_median: string; + declare effective_fee_median: string; + declare total_txs_size: string; declare transaction_details: string; declare miner_txt_info: string; declare pow_seed: string; @@ -38,17 +38,17 @@ AltBlock.init( size: { type: DataTypes.BIGINT, allowNull: true }, hash: { type: DataTypes.STRING, allowNull: true }, type: { type: DataTypes.INTEGER, allowNull: true }, - difficulty: { type: DataTypes.INTEGER, allowNull: true }, - cumulative_diff_adjusted: { type: DataTypes.INTEGER, allowNull: true }, + difficulty: { type: DataTypes.TEXT, allowNull: true }, + cumulative_diff_adjusted: { type: DataTypes.TEXT, allowNull: true }, is_orphan: { type: DataTypes.BOOLEAN, allowNull: true }, - base_reward: { type: DataTypes.INTEGER, allowNull: true }, - total_fee: { type: DataTypes.INTEGER, allowNull: true }, + base_reward: { type: DataTypes.TEXT, allowNull: true }, + total_fee: { type: DataTypes.TEXT, allowNull: true }, penalty: { type: DataTypes.BIGINT, allowNull: true }, summary_reward: { type: DataTypes.BIGINT, allowNull: true }, - block_cumulative_size: { type: DataTypes.INTEGER, allowNull: true }, - this_block_fee_median: { type: DataTypes.INTEGER, allowNull: true }, - effective_fee_median: { type: DataTypes.INTEGER, allowNull: true }, - total_txs_size: { type: DataTypes.INTEGER, allowNull: true }, + block_cumulative_size: { type: DataTypes.TEXT, allowNull: true }, + this_block_fee_median: { type: DataTypes.TEXT, allowNull: true }, + effective_fee_median: { type: DataTypes.TEXT, allowNull: true }, + total_txs_size: { type: DataTypes.TEXT, allowNull: true }, transaction_details: { type: DataTypes.STRING, allowNull: true }, miner_txt_info: { type: DataTypes.STRING, allowNull: true }, pow_seed: { type: DataTypes.STRING, allowNull: true } diff --git a/server/schemes/Block.ts b/server/schemes/Block.ts index 429987c..d6bdf9a 100644 --- a/server/schemes/Block.ts +++ b/server/schemes/Block.ts @@ -5,25 +5,25 @@ class Block extends Model { declare readonly id: number; declare height: number; declare actual_timestamp: Date; - declare base_reward: number; + declare base_reward: string; declare blob: string; - declare block_cumulative_size: number; - declare block_tself_size: number; - declare cumulative_diff_adjusted: number; - declare cumulative_diff_precise: number; - declare difficulty: number; - declare effective_fee_median: number; + declare block_cumulative_size: string; + declare block_tself_size: string; + declare cumulative_diff_adjusted: string; + declare cumulative_diff_precise: string; + declare difficulty: string; + declare effective_fee_median: string; declare tx_id: string; - declare is_orphan: string; - declare penalty: BigInt; + declare is_orphan: boolean; + declare penalty: string; declare prev_id: string; - declare summary_reward: number; - declare this_block_fee_median: number; + declare summary_reward: string; + declare this_block_fee_median: string; declare timestamp: Date; - declare total_fee: number; - declare total_txs_size: number; - declare tr_count: BigInt; - declare type: number; + declare total_fee: string; + declare total_txs_size: string; + declare tr_count: string; + declare type: string; declare miner_text_info: string; declare pow_seed: string; declare already_generated_coins: string; @@ -41,25 +41,25 @@ Block.init( height: { type: DataTypes.INTEGER, allowNull: false }, actual_timestamp: { type: DataTypes.DATE, allowNull: true }, - base_reward: { type: DataTypes.INTEGER, allowNull: true }, + base_reward: { type: DataTypes.TEXT, allowNull: true }, blob: { type: DataTypes.STRING, allowNull: true }, - block_cumulative_size: { type: DataTypes.INTEGER, allowNull: true }, - block_tself_size: { type: DataTypes.INTEGER, allowNull: true }, - cumulative_diff_adjusted: { type: DataTypes.INTEGER, allowNull: true }, - cumulative_diff_precise: { type: DataTypes.INTEGER, allowNull: true }, - difficulty: { type: DataTypes.INTEGER, allowNull: true }, - effective_fee_median: { type: DataTypes.INTEGER, allowNull: true }, + block_cumulative_size: { type: DataTypes.TEXT, allowNull: true }, + block_tself_size: { type: DataTypes.TEXT, allowNull: true }, + cumulative_diff_adjusted: { type: DataTypes.TEXT, allowNull: true }, + cumulative_diff_precise: { type: DataTypes.TEXT, allowNull: true }, + difficulty: { type: DataTypes.TEXT, allowNull: true }, + effective_fee_median: { type: DataTypes.TEXT, allowNull: true }, tx_id: { type: DataTypes.STRING, allowNull: true }, - is_orphan: { type: DataTypes.STRING, allowNull: true }, - penalty: { type: DataTypes.BIGINT, allowNull: true }, + is_orphan: { type: DataTypes.BOOLEAN, allowNull: true }, + penalty: { type: DataTypes.TEXT, allowNull: true }, prev_id: { type: DataTypes.STRING, allowNull: true }, - summary_reward: { type: DataTypes.INTEGER, allowNull: true }, - this_block_fee_median: { type: DataTypes.INTEGER, allowNull: true }, + summary_reward: { type: DataTypes.TEXT, allowNull: true }, + this_block_fee_median: { type: DataTypes.TEXT, allowNull: true }, timestamp: { type: DataTypes.DATE, allowNull: true }, - total_fee: { type: DataTypes.INTEGER, allowNull: true }, - total_txs_size: { type: DataTypes.INTEGER, allowNull: true }, - tr_count: { type: DataTypes.BIGINT, allowNull: true }, - type: { type: DataTypes.INTEGER, allowNull: true }, + total_fee: { type: DataTypes.TEXT, allowNull: true }, + total_txs_size: { type: DataTypes.TEXT, allowNull: true }, + tr_count: { type: DataTypes.TEXT, allowNull: true }, + type: { type: DataTypes.TEXT, allowNull: true }, miner_text_info: { type: DataTypes.STRING, allowNull: true }, pow_seed: { type: DataTypes.STRING, allowNull: true }, already_generated_coins: { type: DataTypes.STRING, allowNull: true }, diff --git a/server/schemes/Chart.ts b/server/schemes/Chart.ts index 027370f..313b946 100644 --- a/server/schemes/Chart.ts +++ b/server/schemes/Chart.ts @@ -5,14 +5,14 @@ class Chart extends Model { declare readonly id: number; declare height: number; declare actual_timestamp: Date; - declare block_cumulative_size: number; - declare cumulative_diff_precise: number; - declare difficulty: number; + declare block_cumulative_size: string; + declare cumulative_diff_precise: string; + declare difficulty: string; declare tr_count: BigInt; - declare type: number; - declare difficulty120?: number; - declare hashrate100?: number; - declare hashrate400?: number; + declare type: string; + declare difficulty120?: string; + declare hashrate100?: string; + declare hashrate400?: string; declare readonly createdAt: Date; declare readonly updatedAt: Date; @@ -26,14 +26,14 @@ Chart.init( height: { type: DataTypes.INTEGER, allowNull: false }, actual_timestamp: { type: DataTypes.DATE, allowNull: true }, - block_cumulative_size: { type: DataTypes.INTEGER, allowNull: true }, - cumulative_diff_precise: { type: DataTypes.INTEGER, allowNull: true }, - difficulty: { type: DataTypes.INTEGER, allowNull: true }, - tr_count: { type: DataTypes.BIGINT, allowNull: true }, - type: { type: DataTypes.INTEGER, allowNull: true }, - difficulty120: { type: DataTypes.INTEGER, allowNull: true }, - hashrate100: { type: DataTypes.INTEGER, allowNull: true }, - hashrate400: { type: DataTypes.INTEGER, allowNull: true } + block_cumulative_size: { type: DataTypes.TEXT, allowNull: true }, + cumulative_diff_precise: { type: DataTypes.TEXT, allowNull: true }, + difficulty: { type: DataTypes.TEXT, allowNull: true }, + tr_count: { type: DataTypes.TEXT, allowNull: true }, + type: { type: DataTypes.TEXT, allowNull: true }, + difficulty120: { type: DataTypes.TEXT, allowNull: true }, + hashrate100: { type: DataTypes.TEXT, allowNull: true }, + hashrate400: { type: DataTypes.TEXT, allowNull: true } }, { sequelize, diff --git a/server/schemes/OutInfo.ts b/server/schemes/OutInfo.ts index 043a995..fc8ff9e 100644 --- a/server/schemes/OutInfo.ts +++ b/server/schemes/OutInfo.ts @@ -3,7 +3,7 @@ import sequelize from "../database/sequelize"; class OutInfo extends Model { declare readonly id: number; - declare amount: number; + declare amount: string; declare i: BigInt; declare tx_id: string; declare block: BigInt; @@ -17,7 +17,7 @@ export type IOutInfo = Omit { + // let id = req.params.id + // const response = await axios({ + // method: 'get', + // url: config.api, + // data: { + // method: 'get_main_block_details', + // params: { + // id: id + // } + // } + // }) + // res.json(response.data) + // }) + // ) + app.get( '/api/get_main_block_details/:id', exceptionHandler(async (req, res) => { - let id = req.params.id - const response = await axios({ - method: 'get', - url: config.api, - data: { - method: 'get_main_block_details', - params: { - id: id - } + try { + let id = req.params.id.toLowerCase() + if (id) { + const result = await getMainBlockDetails(id); + return res.json(result || "Block not found"); } - }) - res.json(response.data) + + res.status(400).json({ error: 'Invalid parameters' }); + } catch (error) { + console.log(error); + res.status(500).json({ error: error.message }); + + } }) - ) + ); + + app.get('/api/ping', exceptionHandler(async (req, res) => { + res.send('pong') + })); app.get( '/api/get_assets/:offset/:count', @@ -229,28 +255,6 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); }) ); - app.get( - '/api/get_blocks_details/:start/:count', - exceptionHandler(async (req, res) => { - let start = req.params.start - let count = req.params.count - const response = await axios({ - method: 'get', - url: config.api, - data: { - method: 'get_blocks_details', - params: { - height_start: parseInt(start ? start : "0", 10), - count: parseInt(count ? count : "10", 10), - ignore_transactions: false - } - } - }) - res.json(response.data) - }) - ) - - app.get( '/api/get_aliases/:offset/:count/:search', exceptionHandler(async (req, res, next) => { @@ -548,7 +552,7 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); try { // Search in the 'blocks' table - let blockResult = await Block.findOne({ where: { id } }); + let blockResult = await Block.findOne({ where: { tx_id: id } }); if (blockResult) { return res.json({ result: 'block' }); } @@ -560,7 +564,7 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); } // Search in the 'transactions' table - let transactionResult = await Transaction.findOne({ where: { id } }); + let transactionResult = await Transaction.findOne({ where: { tx_id: id } }); if (transactionResult) { return res.json({ result: 'tx' }); } @@ -595,6 +599,8 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); // If nothing is found return res.json({ result: 'NOT FOUND' }); } catch (error) { + console.log(error); + next(error); } }) @@ -639,14 +645,20 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); app.get( '/api/get_blocks_details/:start/:count', exceptionHandler(async (req, res) => { - const start = parseInt(req.params.start, 10); - const count = parseInt(req.params.count, 10); - - if (start && count) { - const result = await getBlocksDetails({ start, count }); - res.json(result); - } else { - res.status(400).json({ error: 'Invalid parameters' }); + try { + const start = parseInt(req.params.start, 10); + const count = parseInt(req.params.count, 10); + + if (start && count) { + const result = await getBlocksDetails({ start, count }); + res.json(result); + } else { + res.status(400).json({ error: 'Invalid parameters' }); + } + } catch (error) { + console.log(error); + + res.status(500).json({ error: error.message }); } }) ); @@ -709,19 +721,6 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); }) ); - app.get( - '/api/get_main_block_details/:id', - exceptionHandler(async (req, res) => { - let id = req.params.id.toLowerCase() - if (id) { - const result = await getMainBlockDetails(id); - res.json(result || "Block not found"); - } - - res.status(400).json({ error: 'Invalid parameters' }); - }) - ); - app.get( '/api/get_tx_pool_details/:count', exceptionHandler(async (req, res, next) => { @@ -1018,7 +1017,7 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); let localTr: any; - while (!!(localTr = bl.transactions_details.splice(0, 1)[0])) { + while (!!(localTr = bl.transactions_details.splice(0, 1)[0])) { let response = await get_tx_details(localTr.id); let tx_info = response.data.result.tx_info; @@ -1098,7 +1097,7 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); let response = await get_out_info(localOutAmount, localOut.i); outInfoInserts.push({ - amount: localOut.amount, + amount: localOut.amount?.toString(), i: localOut.i, tx_id: response.data.result.tx_id, block: bl.height, @@ -1169,20 +1168,26 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); }); } - const elementOne = state.block_array[0]; - setLastBlock(state.block_array.pop()); + // const elementOne = state.block_array[0]; + const newLastBlock = state.block_array.pop(); + setLastBlock({ + height: newLastBlock.height, + tx_id: newLastBlock.id, + }); log(`BLOCKS: db = ${lastBlock.height}/ server = ${blockInfo.height}`); - await sequelize.query( - `CALL update_statistics(${Math.min(elementOne.height, lastBlock.height)})`, - { transaction } - ); + // await sequelize.query( + // `CALL update_statistics(${Math.min(elementOne.height, lastBlock.height)})`, + // { transaction } + // ); setState({ ...state, block_array: [], }) } catch (error) { + console.log(error); + log(`SyncTransactions() Transaction Commit ERROR: ${error}`); throw error; } @@ -1205,7 +1210,7 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); let response = await get_blocks_details(lastBlock.height + 1, count); let localBlocks = response.data.result && response.data.result.blocks ? response.data.result.blocks : []; - if (localBlocks.length && lastBlock.id === localBlocks[0].prev_id) { + if (localBlocks.length && lastBlock.tx_id === localBlocks[0].prev_id) { state.block_array = localBlocks; await syncTransactions(); @@ -1239,7 +1244,7 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); } else { setLastBlock({ height: -1, - id: '0000000000000000000000000000000000000000000000000000000000000000' + tx_id: '0000000000000000000000000000000000000000000000000000000000000000' }); } @@ -1517,7 +1522,10 @@ export const io = new Server(server, { transports: ['websocket', 'polling'] }); }); if (lastBlockResult) { - setLastBlock(lastBlockResult.dataValues) + setLastBlock({ + height: lastBlockResult.height, + tx_id: lastBlockResult.tx_id + }); } // Get the count of aliases diff --git a/server/utils/methods.ts b/server/utils/methods.ts index 7269f73..604d708 100644 --- a/server/utils/methods.ts +++ b/server/utils/methods.ts @@ -21,7 +21,7 @@ export async function getBlocksDetails(params: getBlocksDetailsParams) { const result = await Block.findAll({ attributes: [ 'height', - [literal('CASE WHEN type = 0 THEN actual_timestamp ELSE timestamp END'), 'timestamp'], + [literal(`CASE WHEN type = '0' THEN actual_timestamp ELSE timestamp END`), 'timestamp'], 'base_reward', 'blob', 'block_cumulative_size', @@ -30,7 +30,7 @@ export async function getBlocksDetails(params: getBlocksDetailsParams) { 'cumulative_diff_precise', 'difficulty', 'effective_fee_median', - 'id', + 'tx_id', 'is_orphan', 'penalty', 'prev_id', @@ -107,31 +107,30 @@ export async function getVisibilityInfo() { export async function getMainBlockDetails(id: string) { const block = await Block.findOne({ - where: { id: id }, - include: [ - { - model: Block, - as: 'nextBlock', - attributes: ['id'], - where: { - height: { - [Op.gt]: col('Block.height') - } - }, - order: [['height', 'ASC']], - limit: 1, - required: false // left join - } - ] + where: { tx_id: id } }); if (block) { // Find transactions associated with the block + + const nextBlock = await Block.findOne({ + where: { + height: { + [Op.gt]: block.height + } + }, + order: [['height', 'ASC']] + }); + + if (nextBlock) { + block.setDataValue('nextBlock', nextBlock.tx_id); + } + const transactions = await Transaction.findAll({ where: { keeper_block: block.height } }); - - block.setDataValue('transactions_details', transactions); + + block.setDataValue('transactions_details', transactions.map(e => e.toJSON())); return block.toJSON(); } diff --git a/server/utils/states.ts b/server/utils/states.ts index 72b4f14..4043ac3 100644 --- a/server/utils/states.ts +++ b/server/utils/states.ts @@ -15,11 +15,11 @@ export function setBlockInfo(newBlockInfo: IBlockInfo) { export interface ILastBlock { height: number, - id: string + tx_id: string } export let lastBlock: ILastBlock = { height: -1, - id: '0000000000000000000000000000000000000000000000000000000000000000' + tx_id: '0000000000000000000000000000000000000000000000000000000000000000' } export interface State { diff --git a/src/interfaces/common/BlockInfo.ts b/src/interfaces/common/BlockInfo.ts index 7e73f47..c7374e9 100644 --- a/src/interfaces/common/BlockInfo.ts +++ b/src/interfaces/common/BlockInfo.ts @@ -1,7 +1,7 @@ interface BlockInfo { type: "PoS" | "PoW"; - timestamp?: number; - actualTimestamp?: number; + timestamp?: Date; + actualTimestamp?: Date; difficulty: string; minerTextInfo?: string; cummulativeDiffAdjusted?: string; @@ -21,7 +21,7 @@ interface BlockInfo { seed?: string; alreadyGeneratedCoins?: string; object_in_json?: string; - id?: string; + tx_id?: string; prev_id?: string; major_version?: string; minor_version?: string; diff --git a/src/pages/Block/Block.tsx b/src/pages/Block/Block.tsx index b10261a..d329cb7 100644 --- a/src/pages/Block/Block.tsx +++ b/src/pages/Block/Block.tsx @@ -76,9 +76,12 @@ function Block(props: { alt?: boolean }) { if (result.success === false) return; setHeight(result.height || null); + + console.log(result); + setBlockInfo({ - type: result.type === 1 ? "PoW" : "PoS", + type: result.type === "1" ? "PoW" : "PoS", timestamp: result.timestamp || undefined, actualTimestamp: result.actual_timestamp || undefined, difficulty: Utils.formatNumber(result.difficulty || "", 0), @@ -99,7 +102,7 @@ function Block(props: { alt?: boolean }) { transactionsSize: result.total_txs_size || "0", alreadyGeneratedCoins: result.already_generated_coins || undefined, object_in_json: result.object_in_json || undefined, - id: result.id || undefined, + tx_id: result.tx_id || undefined, prev_id: result.prev_id || undefined, minor_version: result?.object_in_json?.split('\"minor_version\": ')?.[1]?.split(',')?.[0] || '-', major_version: result?.object_in_json?.split('\"major_version\": ')?.[1]?.split(',')?.[0] || '-', @@ -120,7 +123,7 @@ function Block(props: { alt?: boolean }) { setTransactions( transactionsDetails.map(e => ({ - hash: e?.id || "", + hash: e?.tx_id || "", fee: Utils.toShiftedNumber(e?.fee || "0", 12), amount: Utils.toShiftedNumber(e?.amount?.toString() || "0", 12), size: e?.blob_size || "0" @@ -190,15 +193,15 @@ function Block(props: { alt?: boolean }) { Timestamp (UTC): - {blockInfo?.timestamp ? Utils.formatTimestampUTC(blockInfo?.timestamp) : "-"} + {blockInfo?.timestamp ? Utils.formatTimestampUTC(+new Date(blockInfo?.timestamp)) : "-"} ID - {Utils.shortenAddress(blockInfo?.id ?? "-")} + {Utils.shortenAddress(blockInfo?.tx_id ?? "-")} Actual Timestamp (UTC): - {blockInfo?.actualTimestamp ? Utils.formatTimestampUTC(blockInfo?.actualTimestamp) : "-"} + {blockInfo?.actualTimestamp ? Utils.formatTimestampUTC(+new Date(blockInfo?.actualTimestamp)) : "-"} Difficulty: diff --git a/src/pages/Blockchain/components/TransactionPool/TransactionPool.tsx b/src/pages/Blockchain/components/TransactionPool/TransactionPool.tsx index 230ef36..2d1620c 100644 --- a/src/pages/Blockchain/components/TransactionPool/TransactionPool.tsx +++ b/src/pages/Blockchain/components/TransactionPool/TransactionPool.tsx @@ -21,12 +21,12 @@ function TransactionPool() { const tableHeaders = [ "TIMESTAMP (UTC)", "AGE", "SIZE", "FEE", "HASH" ]; useEffect(() => { - socket.on("get_transaction_pool_info", (data) => { + socket.on("get_transaction_pool_info", (data: string) => { try { - data = JSON.parse(data); - console.log(data); + const parsedData = JSON.parse(data); + console.log(parsedData); - setPoolElements(data); + setPoolElements(parsedData); } catch (error) { console.error(error); } diff --git a/src/pages/Transaction/Transaction.tsx b/src/pages/Transaction/Transaction.tsx index d0f8633..c789ada 100644 --- a/src/pages/Transaction/Transaction.tsx +++ b/src/pages/Transaction/Transaction.tsx @@ -41,7 +41,7 @@ function Transaction() { if (result.success === false) return; if (!(typeof result === "object")) return; const newTransactionInfo: TransactionInfo = { - hash: result.id || "", + hash: result.hash || "", amount: Utils.toShiftedNumber(result.amount || "0", 12), fee: Utils.toShiftedNumber(result.fee || "0", 12), size: result.blob_size || "0", diff --git a/src/utils/methods.ts b/src/utils/methods.ts index 92cda53..a419b32 100644 --- a/src/utils/methods.ts +++ b/src/utils/methods.ts @@ -42,7 +42,7 @@ class Fetch { if (result.success === false) return null; if (!(result instanceof Array)) return null; - const hash = result[0]?.id; + const hash = result[0]?.tx_id; if (typeof hash !== "string") return ""; diff --git a/src/utils/socket.ts b/src/utils/socket.ts index fecadab..8e2cca2 100644 --- a/src/utils/socket.ts +++ b/src/utils/socket.ts @@ -4,5 +4,9 @@ import { SERVER_PORT_DEV } from '../config/config'; // "undefined" means the URL will be computed from the `window.location` object const URL = process.env.NODE_ENV === 'production' ? undefined : `http://localhost:${SERVER_PORT_DEV}`; + +console.log("URL", URL); + + // @ts-ignore export const socket = io(URL); \ No newline at end of file diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 6971325..22acded 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -4,7 +4,7 @@ import { chartDataFieldMap, chartRequestNames } from "./constants"; import Fetch from "./methods"; class Utils { - static shortenAddress(address: string): string { + static shortenAddress(address: string): string { if (address.length < 10) return address; return address.slice(0, 6) + "..." + address.slice(-4); }