From e8ff4396aa7af992499dcaffc6a182832e32414a Mon Sep 17 00:00:00 2001 From: Flummi Date: Sun, 2 Jan 2022 06:52:47 +0100 Subject: [PATCH] migration to postgresql --- package-lock.json | 660 ++++++++++++++++++++++----------- package.json | 7 +- src/inc/lib.mjs | 2 +- src/inc/routes/admin.mjs | 2 +- src/inc/routes/apiv2.mjs | 11 +- src/inc/routes/inc/f0cklib.mjs | 131 +++++-- src/inc/routes/index.mjs | 10 +- src/inc/routes/random.mjs | 5 +- src/inc/sql.mjs | 14 +- src/inc/trigger/parser.mjs | 7 +- src/index.mjs | 2 +- 11 files changed, 571 insertions(+), 280 deletions(-) diff --git a/package-lock.json b/package-lock.json index 686118d..327660b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,25 +11,32 @@ "dependencies": { "cuffeo": "^1.0.7-3", "flumm-fetch-cookies": "^1.4.0", - "flummpress": "^2.0.0", - "knex": "^0.95.4", - "mariadb": "^2.5.2" + "flummpress": "^2.0.1", + "knex": "^0.95.15", + "pg": "^8.7.1", + "pg-native": "^3.0.0" } }, - "node_modules/@types/geojson": { - "version": "7946.0.7", - "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.7.tgz", - "integrity": "sha512-wE2v81i4C4Ol09RtsWFAqg3BUitWbHSpSlIo+bNdsCJijO9sjme+zm+73ZMCa/qMC8UEERxzGbvmr1cffo2SiQ==" + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dependencies": { + "file-uri-to-path": "1.0.0" + } }, - "node_modules/@types/node": { - "version": "14.14.44", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.44.tgz", - "integrity": "sha512-+gaugz6Oce6ZInfI/tK4Pq5wIIkJMEJUu92RB3Eu93mtj4wjjjz9EB5mLp5s1pSsLXdC/CPut/xF20ZzAQJbTA==" + "node_modules/buffer-writer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", + "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==", + "engines": { + "node": ">=4" + } }, "node_modules/colorette": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz", - "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==" + "version": "2.0.16", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.16.tgz", + "integrity": "sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==" }, "node_modules/commander": { "version": "7.2.0", @@ -39,6 +46,11 @@ "node": ">= 10" } }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "node_modules/cuffeo": { "version": "1.0.7-3", "resolved": "https://registry.npmjs.org/cuffeo/-/cuffeo-1.0.7-3.tgz", @@ -48,9 +60,9 @@ } }, "node_modules/debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", "dependencies": { "ms": "2.1.2" }, @@ -63,14 +75,6 @@ } } }, - "node_modules/denque": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", - "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==", - "engines": { - "node": ">=0.10" - } - }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -87,6 +91,11 @@ "node": ">=6" } }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, "node_modules/flumm-fetch": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/flumm-fetch/-/flumm-fetch-1.0.1.tgz", @@ -104,9 +113,9 @@ } }, "node_modules/flummpress": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/flummpress/-/flummpress-2.0.0.tgz", - "integrity": "sha512-4W2mTpOJI4QMVXBO09dJNK9L9GUu+bXib/jrjZV8XxZkU2LQqZhvVc6/eIhDbWJDH0+6dIotrS9k5IKwJRFczw==" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flummpress/-/flummpress-2.0.1.tgz", + "integrity": "sha512-5V52dJ7vh+ZRwkpw8i8K7sBKNhw3bNVOeKiq9nDuFgE8cvk3N6gc2UWwjz/V7sx0Bk8BsrJgiBGMf8G7m9J29w==" }, "node_modules/function-bind": { "version": "1.1.1", @@ -129,16 +138,10 @@ "node": ">= 0.4.0" } }, - "node_modules/iconv-lite": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.2.tgz", - "integrity": "sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/interpret": { "version": "2.2.0", @@ -149,9 +152,9 @@ } }, "node_modules/is-core-module": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz", - "integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz", + "integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==", "dependencies": { "has": "^1.0.3" }, @@ -159,21 +162,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, "node_modules/knex": { - "version": "0.95.4", - "resolved": "https://registry.npmjs.org/knex/-/knex-0.95.4.tgz", - "integrity": "sha512-IwUcHr6AkZPL707mJCOal1P4jlgxKMy17IMjJm5W23yrkM1jO2/APBM1eyw/MhQ61w8T7NpzGD+LEkr8M46mWw==", + "version": "0.95.15", + "resolved": "https://registry.npmjs.org/knex/-/knex-0.95.15.tgz", + "integrity": "sha512-Loq6WgHaWlmL2bfZGWPsy4l8xw4pOE+tmLGkPG0auBppxpI0UcK+GYCycJcqz9W54f2LiGewkCVLBm3Wq4ur/w==", "dependencies": { - "colorette": "1.2.1", + "colorette": "2.0.16", "commander": "^7.1.0", - "debug": "4.3.1", + "debug": "4.3.2", "escalade": "^3.1.1", "esm": "^3.2.25", "getopts": "2.2.5", "interpret": "^2.2.0", "lodash": "^4.17.21", - "pg-connection-string": "2.4.0", - "rechoir": "^0.7.0", + "pg-connection-string": "2.5.0", + "rechoir": "0.7.0", "resolve-from": "^5.0.0", "tarn": "^3.0.1", "tildify": "2.0.0" @@ -184,13 +192,6 @@ "engines": { "node": ">=10" }, - "peerDependencies": { - "mysql": "^2.18.1", - "mysql2": "^2.2.5", - "pg": "^8.5.1", - "sqlite3": "^5.0.0", - "tedious": "^11.0.5" - }, "peerDependenciesMeta": { "mysql": { "optional": true @@ -201,6 +202,9 @@ "pg": { "optional": true }, + "pg-native": { + "optional": true + }, "sqlite3": { "optional": true }, @@ -209,73 +213,189 @@ } } }, + "node_modules/libpq": { + "version": "1.8.9", + "resolved": "https://registry.npmjs.org/libpq/-/libpq-1.8.9.tgz", + "integrity": "sha512-herU0STiW3+/XBoYRycKKf49O9hBKK0JbdC2QmvdC5pyCSu8prb9idpn5bUSbxj8XwcEsWPWWWwTDZE9ZTwJ7g==", + "hasInstallScript": true, + "dependencies": { + "bindings": "1.5.0", + "nan": "^2.14.0" + } + }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "node_modules/long": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" - }, - "node_modules/mariadb": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/mariadb/-/mariadb-2.5.3.tgz", - "integrity": "sha512-9ZbQ1zLqasLCQy6KDcPHtX7EUIMBlQ8p64gNR61+yfpCIWjPDji3aR56LvwbOz1QnQbVgYBOJ4J/pHoFN5MR+w==", - "dependencies": { - "@types/geojson": "^7946.0.7", - "@types/node": "^14.14.28", - "denque": "^1.4.1", - "iconv-lite": "^0.6.2", - "long": "^4.0.0", - "moment-timezone": "^0.5.33", - "please-upgrade-node": "^3.2.0" - }, - "engines": { - "node": ">= 10.13" - } - }, - "node_modules/moment": { - "version": "2.29.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", - "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", - "engines": { - "node": "*" - } - }, - "node_modules/moment-timezone": { - "version": "0.5.33", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz", - "integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==", - "dependencies": { - "moment": ">= 2.9.0" - }, - "engines": { - "node": "*" - } - }, "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/nan": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", + "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==" + }, + "node_modules/packet-reader": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", + "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" + }, "node_modules/path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "node_modules/pg": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.7.1.tgz", + "integrity": "sha512-7bdYcv7V6U3KAtWjpQJJBww0UEsWuh4yQ/EjNf2HeO/NnvKjpvhEIe/A/TleP6wtmSKnUnghs5A9jUoK6iDdkA==", + "dependencies": { + "buffer-writer": "2.0.0", + "packet-reader": "1.0.0", + "pg-connection-string": "^2.5.0", + "pg-pool": "^3.4.1", + "pg-protocol": "^1.5.0", + "pg-types": "^2.1.0", + "pgpass": "1.x" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "pg-native": ">=2.0.0" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } }, "node_modules/pg-connection-string": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz", - "integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz", + "integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ==" }, - "node_modules/please-upgrade-node": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", - "integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==", + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-native": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pg-native/-/pg-native-3.0.0.tgz", + "integrity": "sha512-qZZyywXJ8O4lbiIN7mn6vXIow1fd3QZFqzRe+uET/SZIXvCa3HBooXQA4ZU8EQX8Ae6SmaYtDGLp5DwU+8vrfg==", "dependencies": { - "semver-compare": "^1.0.0" + "libpq": "^1.7.0", + "pg-types": "^1.12.1", + "readable-stream": "1.0.31" + } + }, + "node_modules/pg-native/node_modules/pg-types": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-1.13.0.tgz", + "integrity": "sha512-lfKli0Gkl/+za/+b6lzENajczwZHc7D5kiUCZfgm914jipD2kIOIvEkAhZ8GrW3/TUoP9w8FHjwpPObBye5KQQ==", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~1.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.0", + "postgres-interval": "^1.1.0" + } + }, + "node_modules/pg-native/node_modules/postgres-array": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-1.0.3.tgz", + "integrity": "sha512-5wClXrAP0+78mcsNX3/ithQ5exKvCyK5lr5NEEEeGwwM6NJdQgzIJBVxLvRW+huFpX92F2QnZ5CcokH0VhK2qQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pg-pool": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.4.1.tgz", + "integrity": "sha512-TVHxR/gf3MeJRvchgNHxsYsTCHQ+4wm3VIHSS19z8NC0+gioEhq1okDY1sm/TYbfoP6JLFx01s0ShvZ3puP/iQ==", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.5.0.tgz", + "integrity": "sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ==" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/readable-stream": { + "version": "1.0.31", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.31.tgz", + "integrity": "sha1-jyUC4LyeOw2huUUgqrtOJgPsr64=", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" } }, "node_modules/rechoir": { @@ -309,20 +429,23 @@ "node": ">=8" } }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "node_modules/split2": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz", + "integrity": "sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ==", + "engines": { + "node": ">= 10.x" + } }, - "node_modules/semver-compare": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", - "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=" + "node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" }, "node_modules/tarn": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/tarn/-/tarn-3.0.1.tgz", - "integrity": "sha512-6usSlV9KyHsspvwu2duKH+FMUhqJnAh6J5J/4MITl8s94iSUQTLkJggdiewKv4RyARQccnigV48Z+khiuVZDJw==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tarn/-/tarn-3.0.2.tgz", + "integrity": "sha512-51LAVKUSZSVfI05vjPESNc5vwqqZpbXCsU+/+wxlOrUjk2SnFTt97v9ZgQrD4YmxYW1Px6w2KjaDitCfkvgxMQ==", "engines": { "node": ">=8.0.0" } @@ -334,29 +457,45 @@ "engines": { "node": ">=8" } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } } }, "dependencies": { - "@types/geojson": { - "version": "7946.0.7", - "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.7.tgz", - "integrity": "sha512-wE2v81i4C4Ol09RtsWFAqg3BUitWbHSpSlIo+bNdsCJijO9sjme+zm+73ZMCa/qMC8UEERxzGbvmr1cffo2SiQ==" + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } }, - "@types/node": { - "version": "14.14.44", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.44.tgz", - "integrity": "sha512-+gaugz6Oce6ZInfI/tK4Pq5wIIkJMEJUu92RB3Eu93mtj4wjjjz9EB5mLp5s1pSsLXdC/CPut/xF20ZzAQJbTA==" + "buffer-writer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", + "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==" }, "colorette": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz", - "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==" + "version": "2.0.16", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.16.tgz", + "integrity": "sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==" }, "commander": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==" }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "cuffeo": { "version": "1.0.7-3", "resolved": "https://registry.npmjs.org/cuffeo/-/cuffeo-1.0.7-3.tgz", @@ -366,18 +505,13 @@ } }, "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", "requires": { "ms": "2.1.2" } }, - "denque": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", - "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==" - }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -388,6 +522,11 @@ "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==" }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, "flumm-fetch": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/flumm-fetch/-/flumm-fetch-1.0.1.tgz", @@ -402,9 +541,9 @@ } }, "flummpress": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/flummpress/-/flummpress-2.0.0.tgz", - "integrity": "sha512-4W2mTpOJI4QMVXBO09dJNK9L9GUu+bXib/jrjZV8XxZkU2LQqZhvVc6/eIhDbWJDH0+6dIotrS9k5IKwJRFczw==" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flummpress/-/flummpress-2.0.1.tgz", + "integrity": "sha512-5V52dJ7vh+ZRwkpw8i8K7sBKNhw3bNVOeKiq9nDuFgE8cvk3N6gc2UWwjz/V7sx0Bk8BsrJgiBGMf8G7m9J29w==" }, "function-bind": { "version": "1.1.1", @@ -424,13 +563,10 @@ "function-bind": "^1.1.1" } }, - "iconv-lite": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.2.tgz", - "integrity": "sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - } + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "interpret": { "version": "2.2.0", @@ -438,91 +574,188 @@ "integrity": "sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==" }, "is-core-module": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz", - "integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz", + "integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==", "requires": { "has": "^1.0.3" } }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, "knex": { - "version": "0.95.4", - "resolved": "https://registry.npmjs.org/knex/-/knex-0.95.4.tgz", - "integrity": "sha512-IwUcHr6AkZPL707mJCOal1P4jlgxKMy17IMjJm5W23yrkM1jO2/APBM1eyw/MhQ61w8T7NpzGD+LEkr8M46mWw==", + "version": "0.95.15", + "resolved": "https://registry.npmjs.org/knex/-/knex-0.95.15.tgz", + "integrity": "sha512-Loq6WgHaWlmL2bfZGWPsy4l8xw4pOE+tmLGkPG0auBppxpI0UcK+GYCycJcqz9W54f2LiGewkCVLBm3Wq4ur/w==", "requires": { - "colorette": "1.2.1", + "colorette": "2.0.16", "commander": "^7.1.0", - "debug": "4.3.1", + "debug": "4.3.2", "escalade": "^3.1.1", "esm": "^3.2.25", "getopts": "2.2.5", "interpret": "^2.2.0", "lodash": "^4.17.21", - "pg-connection-string": "2.4.0", - "rechoir": "^0.7.0", + "pg-connection-string": "2.5.0", + "rechoir": "0.7.0", "resolve-from": "^5.0.0", "tarn": "^3.0.1", "tildify": "2.0.0" } }, + "libpq": { + "version": "1.8.9", + "resolved": "https://registry.npmjs.org/libpq/-/libpq-1.8.9.tgz", + "integrity": "sha512-herU0STiW3+/XBoYRycKKf49O9hBKK0JbdC2QmvdC5pyCSu8prb9idpn5bUSbxj8XwcEsWPWWWwTDZE9ZTwJ7g==", + "requires": { + "bindings": "1.5.0", + "nan": "^2.14.0" + } + }, "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "long": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" - }, - "mariadb": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/mariadb/-/mariadb-2.5.3.tgz", - "integrity": "sha512-9ZbQ1zLqasLCQy6KDcPHtX7EUIMBlQ8p64gNR61+yfpCIWjPDji3aR56LvwbOz1QnQbVgYBOJ4J/pHoFN5MR+w==", - "requires": { - "@types/geojson": "^7946.0.7", - "@types/node": "^14.14.28", - "denque": "^1.4.1", - "iconv-lite": "^0.6.2", - "long": "^4.0.0", - "moment-timezone": "^0.5.33", - "please-upgrade-node": "^3.2.0" - } - }, - "moment": { - "version": "2.29.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", - "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" - }, - "moment-timezone": { - "version": "0.5.33", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz", - "integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==", - "requires": { - "moment": ">= 2.9.0" - } - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "nan": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", + "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==" + }, + "packet-reader": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", + "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" + }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "pg": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.7.1.tgz", + "integrity": "sha512-7bdYcv7V6U3KAtWjpQJJBww0UEsWuh4yQ/EjNf2HeO/NnvKjpvhEIe/A/TleP6wtmSKnUnghs5A9jUoK6iDdkA==", + "requires": { + "buffer-writer": "2.0.0", + "packet-reader": "1.0.0", + "pg-connection-string": "^2.5.0", + "pg-pool": "^3.4.1", + "pg-protocol": "^1.5.0", + "pg-types": "^2.1.0", + "pgpass": "1.x" + } }, "pg-connection-string": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz", - "integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz", + "integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ==" }, - "please-upgrade-node": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", - "integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==", + "pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==" + }, + "pg-native": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pg-native/-/pg-native-3.0.0.tgz", + "integrity": "sha512-qZZyywXJ8O4lbiIN7mn6vXIow1fd3QZFqzRe+uET/SZIXvCa3HBooXQA4ZU8EQX8Ae6SmaYtDGLp5DwU+8vrfg==", "requires": { - "semver-compare": "^1.0.0" + "libpq": "^1.7.0", + "pg-types": "^1.12.1", + "readable-stream": "1.0.31" + }, + "dependencies": { + "pg-types": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-1.13.0.tgz", + "integrity": "sha512-lfKli0Gkl/+za/+b6lzENajczwZHc7D5kiUCZfgm914jipD2kIOIvEkAhZ8GrW3/TUoP9w8FHjwpPObBye5KQQ==", + "requires": { + "pg-int8": "1.0.1", + "postgres-array": "~1.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.0", + "postgres-interval": "^1.1.0" + } + }, + "postgres-array": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-1.0.3.tgz", + "integrity": "sha512-5wClXrAP0+78mcsNX3/ithQ5exKvCyK5lr5NEEEeGwwM6NJdQgzIJBVxLvRW+huFpX92F2QnZ5CcokH0VhK2qQ==" + } + } + }, + "pg-pool": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.4.1.tgz", + "integrity": "sha512-TVHxR/gf3MeJRvchgNHxsYsTCHQ+4wm3VIHSS19z8NC0+gioEhq1okDY1sm/TYbfoP6JLFx01s0ShvZ3puP/iQ==", + "requires": {} + }, + "pg-protocol": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.5.0.tgz", + "integrity": "sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ==" + }, + "pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "requires": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + } + }, + "pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "requires": { + "split2": "^4.1.0" + } + }, + "postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==" + }, + "postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=" + }, + "postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==" + }, + "postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "requires": { + "xtend": "^4.0.0" + } + }, + "readable-stream": { + "version": "1.0.31", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.31.tgz", + "integrity": "sha1-jyUC4LyeOw2huUUgqrtOJgPsr64=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" } }, "rechoir": { @@ -547,25 +780,30 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==" }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "split2": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz", + "integrity": "sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ==" }, - "semver-compare": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", - "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=" + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" }, "tarn": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/tarn/-/tarn-3.0.1.tgz", - "integrity": "sha512-6usSlV9KyHsspvwu2duKH+FMUhqJnAh6J5J/4MITl8s94iSUQTLkJggdiewKv4RyARQccnigV48Z+khiuVZDJw==" + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tarn/-/tarn-3.0.2.tgz", + "integrity": "sha512-51LAVKUSZSVfI05vjPESNc5vwqqZpbXCsU+/+wxlOrUjk2SnFTt97v9ZgQrD4YmxYW1Px6w2KjaDitCfkvgxMQ==" }, "tildify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/tildify/-/tildify-2.0.0.tgz", "integrity": "sha512-Cc+OraorugtXNfs50hU9KS369rFXCfgGLpfCfvlc+Ud5u6VWmUQsOAa9HbTvheQdYnrdJqqv1e5oIqXppMYnSw==" + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" } } } diff --git a/package.json b/package.json index 14d8c2a..ab46ee7 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,9 @@ "dependencies": { "cuffeo": "^1.0.7-3", "flumm-fetch-cookies": "^1.4.0", - "flummpress": "^2.0.0", - "knex": "^0.95.4", - "mariadb": "^2.5.2" + "flummpress": "^2.0.1", + "knex": "^0.95.15", + "pg": "^8.7.1", + "pg-native": "^3.0.0" } } diff --git a/src/inc/lib.mjs b/src/inc/lib.mjs index e7de31d..ec1142b 100644 --- a/src/inc/lib.mjs +++ b/src/inc/lib.mjs @@ -80,7 +80,7 @@ export default new class { return { tagged, untagged, - total: tagged + untagged, + total: +tagged + +untagged, sfw, nsfw }; diff --git a/src/inc/routes/admin.mjs b/src/inc/routes/admin.mjs index 9838381..5a98678 100644 --- a/src/inc/routes/admin.mjs +++ b/src/inc/routes/admin.mjs @@ -29,7 +29,7 @@ export default (router, tpl) => { return res.reply({ body: "user doesn't exist or wrong password" }); if(!(await lib.verify(req.post.password, user[0].password))) return res.reply({ body: "user doesn't exist or wrong password" }); - const stamp = Date.now() / 1e3; + const stamp = ~~(Date.now() / 1e3); const session = lib.md5(lib.createID()); await sql("user_sessions").insert({ diff --git a/src/inc/routes/apiv2.mjs b/src/inc/routes/apiv2.mjs index f33ba77..27bfaa4 100644 --- a/src/inc/routes/apiv2.mjs +++ b/src/inc/routes/apiv2.mjs @@ -107,9 +107,10 @@ export default (router, tpl) => { let tagid; const tag_exists = await sql("tags").select("id", "tag").where("tag", tag); if(tag_exists.length === 0) { // create new tag - tagid = (await sql("tags").insert({ + await sql("tags").insert({ tag: tag - }))[0]; + }); + tagid = (await sql("tags").select("id").where("tag", tag))[0].id; } else { tagid = tag_exists[0].id; @@ -207,7 +208,11 @@ export default (router, tpl) => { }); } - favs = await sql('favorites').select('user_id').where('item_id', itemid); + favs = await sql('favorites') + .select('user.user', 'user_options.avatar') + .leftJoin('user', 'user.id', 'favorites.user_id') + .leftJoin('user_options', 'user_options.user_id', 'favorites.user_id') + .where('favorites.item_id', itemid); res.reply({ body: JSON.stringify({ success: true, diff --git a/src/inc/routes/inc/f0cklib.mjs b/src/inc/routes/inc/f0cklib.mjs index 2989755..2dd8447 100644 --- a/src/inc/routes/inc/f0cklib.mjs +++ b/src/inc/routes/inc/f0cklib.mjs @@ -3,9 +3,10 @@ import lib from "../../lib.mjs"; import cfg from "../../config.mjs"; import fs from "fs"; import url from "url"; +import { ifError } from "assert"; export default { - getf0cks: async (o = { user, tag, mime, page, mode }) => { + getf0cks: async (o = { user, tag, mime, page, mode, fav }) => { const user = o.user ? decodeURI(o.user) : null; const tag = lib.parseTag(o.tag ?? null); const mime = (o.mime ?? ""); @@ -33,23 +34,40 @@ export default { .select("tags_assign.item_id", "tags.tag") .leftJoin("tags_assign", "tags_assign.tag_id", "tags.id") .where("tags.tag", "like", "%"+tag+"%") - .groupBy("tags_assign.item_id") + .groupBy("tags_assign.item_id", "tags.tag") .as("st"), "st.item_id", "items.id" ) .whereRaw(modequery) + .groupBy('items.id', 'st.tag', 'st.item_id') .count("* as total") )[0]?.total; } else { - total = (await sql("items") - .whereRaw(modequery) - .andWhere("items.mime", "like", smime) - .andWhere("items.username", "like", user ? user : "%") - .count("* as total") - )[0]?.total; + if(!o.fav) { + total = (await sql("items") + .whereRaw(modequery) + .andWhere("items.mime", "ilike", smime) + .andWhere("items.username", "ilike", user ? user : "%") + .count("* as total") + )[0]?.total; + } + else { + total = (await sql("favorites") + .select('items.id', 'items.mime') + .leftJoin('user', 'user.id', 'favorites.user_id') + .leftJoin('tags_assign', 'tags_assign.item_id', 'favorites.item_id') + .leftJoin('tags', 'tags.id', 'tags_assign.tag_id') + .leftJoin('items', 'items.id', 'favorites.item_id') + .whereRaw(modequery) + .andWhere('items.mime', 'ilike', smime) + .andWhere('user.user', 'ilike', user) + .groupBy('items.id') + .count('* as total') + )[0]?.total; + } } - + if(!total || total.length === 0) return { success: false, @@ -59,27 +77,47 @@ export default { const pages = +Math.ceil(total / cfg.websrv.eps); const act_page = Math.min(pages, page || 1); const offset = Math.max(0, (act_page - 1) * cfg.websrv.eps); + + let rows; - let rows = sql("items") - .select("items.id", "items.mime", "tags_assign.tag_id") - .joinRaw("left join tags_assign on tags_assign.item_id = items.id and (tags_assign.tag_id = 1 or tags_assign.tag_id = 2)") - .whereRaw(modequery) - .andWhere("items.mime", "like", smime) - .andWhere("items.username", "like", user ? user : "%") - .orderBy("items.id", "desc") - .offset(offset) - .limit(cfg.websrv.eps); + if(!o.fav) { + rows = sql("items") + .select("items.id", "items.mime", "tags_assign.tag_id") + .joinRaw("left join tags_assign on tags_assign.item_id = items.id and (tags_assign.tag_id = 1 or tags_assign.tag_id = 2)") + .whereRaw(modequery) + .andWhere("items.mime", "ilike", smime) + .andWhere("items.username", "ilike", user ? user : "%") + .orderBy("items.id", "desc") + .offset(offset) + .limit(cfg.websrv.eps); + } + else { + rows = sql("favorites") + .select('items.id', 'items.mime') + .leftJoin('user', 'user.id', 'favorites.user_id') + .leftJoin('tags_assign', 'tags_assign.item_id', 'favorites.item_id') + .leftJoin('tags', 'tags.id', 'tags_assign.tag_id') + .leftJoin('items', 'items.id', 'favorites.item_id') + .whereRaw(modequery) + .andWhere('items.mime', 'ilike', smime) + .andWhere('user.user', 'ilike', user) + .orderBy('items.id', 'desc') + .groupBy('items.id') + .offset(offset) + .limit(cfg.websrv.eps); + } if(tag) rows = rows .innerJoin( sql("tags") .select("tags_assign.item_id", "tags.tag") .leftJoin("tags_assign", "tags_assign.tag_id", "tags.id") - .where("tags.tag", "like", "%"+tag+"%") - .groupBy("tags_assign.item_id") + .where("tags.tag", "ilike", "%"+tag+"%") + .groupBy("tags_assign.item_id", "tags.tag") .as("st"), "st.item_id", "items.id" - ); + ) + .groupBy('st.item_id'); rows = await rows; @@ -99,7 +137,7 @@ export default { for(let i = Math.max(1, act_page - 3); i <= Math.min(act_page + 3, pages); i++) cheat.push(i); - const link = lib.genLink({ user, tag, mime, act_page }); + const link = lib.genLink({ user, tag, mime, type: o.fav ? 'favs' : 'f0cks' }); data = { success: true, @@ -136,26 +174,42 @@ export default { }; } - let items = sql("items") - .select("*") - .orderBy("items.id", "desc") - .whereRaw(modequery); + let items; + + if(o.fav) { + items = sql('favorites') + .select('items.*') + .leftJoin('items', 'items.id', 'favorites.item_id') + .leftJoin('user', 'user.id', 'favorites.user_id') + .whereRaw(modequery) + .andWhere('user.user', 'ilike', user) + .groupBy('items.id'); + } + else { + items = sql("items") + .select("*") + .orderBy("items.id", "desc") + .whereRaw(modequery); + } if(tag) { items = items.innerJoin( sql("tags") .select("tags_assign.item_id", "tags.tag") .leftJoin("tags_assign", "tags_assign.tag_id", "tags.id") - .where("tags.tag", "like", "%"+tag+"%") - .groupBy("tags_assign.item_id") + .where("tags.tag", "ilike", "%"+tag+"%") + .groupBy("tags_assign.item_id", "tags.tag") .as("st"), "st.item_id", "items.id" - ); + ) + .groupBy('items.id', 'st.item_id', 'st.tag'); } - if(user) - items = items.andWhere("username", "like", "%" + user + "%"); + else + items = items.groupBy('items.id'); + if(user && !o.fav) + items = items.andWhere("items.username", "ilike", "%" + user + "%"); if(mime) - items = items.andWhere("mime", "like", mime + "/%"); + items = items.andWhere("items.mime", "ilike", mime + "/%"); items = await items; @@ -171,7 +225,7 @@ export default { const tags = await lib.getTags(itemid); const cheat = items.slice(Math.max(0, item - 3), item + 4).map(i => i.id); - const link = lib.genLink({ user, tag, mime, act_page: itemid }); + const link = lib.genLink({ user, tag, mime, type: o.fav ? 'favs' : 'f0cks' }); const favorites = await sql('favorites') .select('user.user', 'user_options.avatar') .leftJoin('user', 'user.id', 'favorites.user_id') @@ -228,23 +282,24 @@ export default { const modequery = mime == "audio" ? lib.getMode(0) : lib.getMode(o.mode ?? 0); - let item = sql("items").select("*").orderByRaw("rand()").whereRaw(modequery); + let item = sql("items").select("*").orderByRaw("random()").whereRaw(modequery); if(tag) { item = item.innerJoin( sql("tags") .select("tags_assign.item_id", "tags.tag") .leftJoin("tags_assign", "tags_assign.tag_id", "tags.id") - .where("tags.tag", "like", "%"+tag+"%") + .where("tags.tag", "ilike", "%"+tag+"%") .groupBy("tags_assign.item_id") .as("st"), "st.item_id", "items.id" - ); + ) + .groupBy('st.item_id'); } if(user) - item = item.andWhere("username", "like", "%" + user + "%"); + item = item.andWhere("username", "ilike", "%" + user + "%"); if(mime) - item = item.andWhere("mime", "like", mime + "/%"); + item = item.andWhere("mime", "ilike", mime + "/%"); item = await item; diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs index 7294551..d27695d 100644 --- a/src/inc/routes/index.mjs +++ b/src/inc/routes/index.mjs @@ -10,7 +10,7 @@ const auth = async (req, res, next) => { }; export default (router, tpl) => { - router.get(/^\/?(?:\/tag\/(?.+?))?(?:\/user\/(?.+?)\/(?:f0cks|favs))?(?:\/(?image|audio|video))?(?:\/p\/(?\d+))?(?:\/(?\d+))?$/, async (req, res) => { + router.get(/^\/?(?:\/tag\/(?.+?))?(?:\/user\/(?.+?)\/(?f0cks|favs))?(?:\/(?image|audio|video))?(?:\/p\/(?\d+))?(?:\/(?\d+))?$/, async (req, res) => { const mode = req.params.itemid ? 'item' : 'index'; const data = await (req.params.itemid ? f0cklib.getf0ck : f0cklib.getf0cks)({ user: req.params.user, @@ -18,6 +18,7 @@ export default (router, tpl) => { mime: req.params.mime, page: req.params.page, itemid: req.params.itemid, + fav: req.params.mode == 'favs', mode: req.session.mode }); if(!data.success) { @@ -44,7 +45,7 @@ export default (router, tpl) => { let referertmp = req.headers.referer; let referer = ""; - if(referertmp.match(/f0ck\.me/)) + if(referertmp?.match(/f0ck\.me/)) referer = referertmp.split("/").slice(3).join("/"); if(cfg.allowedModes[mode]) { @@ -63,10 +64,11 @@ export default (router, tpl) => { router.get(/^\/ranking$/, async (req, res) => { try { const list = await sql('tags_assign') - .select('user.user', sql.raw('count(distinct tag_id, item_id) count')) + .select('user.user') .leftJoin('user', 'user.id', 'tags_assign.user_id') .groupBy('user.user') - .orderBy('count', 'desc'); + .orderBy('count', 'desc') + .countDistinct('tag_id', 'item_id', { as: 'count' }); const stats = await lib.countf0cks(); diff --git a/src/inc/routes/random.mjs b/src/inc/routes/random.mjs index 62a23c8..c573781 100644 --- a/src/inc/routes/random.mjs +++ b/src/inc/routes/random.mjs @@ -2,12 +2,12 @@ import f0cklib from "./inc/f0cklib.mjs"; export default (router, tpl) => { router.get(/^\/random$/, async (req, res) => { - let referer = req.headers.referer; + let referer = req.headers.referer ?? ''; let opts = {}; if(referer.match(/f0ck\.me/)) { // parse referer referer = referer.split("f0ck.me")[1]; - const tmp = referer.match(/^\/?(?:\/tag\/(?.+?))?(?:\/user\/(?.+?)\/(?:f0cks|favs))?(?:\/(?image|audio|video))?(?:\/p\/(?\d+))?(?:\/(?\d+))?$/); + const tmp = referer.match(/^\/?(?:\/tag\/(?.+?))?(?:\/user\/(?.+?)\/(?f0cks|favs))?(?:\/(?image|audio|video))?(?:\/p\/(?\d+))?(?:\/(?\d+))?$/); if(tmp) opts = tmp.groups; } @@ -17,6 +17,7 @@ export default (router, tpl) => { tag: opts.tag, mime: opts.mime, page: opts.page, + fav: opts.mode == 'favs', mode: req.session.mode }); diff --git a/src/inc/sql.mjs b/src/inc/sql.mjs index e4e55d2..720c73c 100644 --- a/src/inc/sql.mjs +++ b/src/inc/sql.mjs @@ -1,19 +1,7 @@ import knex from "knex"; -import callback from "mariadb/callback.js"; -import Client_MySQL from "knex/lib/dialects/mysql/index.js"; import cfg from "./config.mjs"; -class Client_MariaDB extends Client_MySQL { - driverName = "mariadb"; - _driver() { - return callback; - } - validateConnection(conn) { - return conn.isValid(); - } -}; - export default knex({ - client: Client_MariaDB, + client: 'pgnative', connection: cfg.sql }); diff --git a/src/inc/trigger/parser.mjs b/src/inc/trigger/parser.mjs index 06ce4f4..d0966be 100644 --- a/src/inc/trigger/parser.mjs +++ b/src/inc/trigger/parser.mjs @@ -50,7 +50,7 @@ export default async bot => { return e.reply(`repost motherf0cker (link): ${cfg.main.url}/${q_repost[0].id}`); // generate uuid - const uuid = (await sql.select(sql.raw("left(uuid(), 8) as uuid")))[0].uuid; + const uuid = (await sql.select(sql.raw("gen_random_uuid() as uuid")))[0].uuid.substring(0, 8); const maxfilesize = (getLevel(e.user).level > 50 ? cfg.main.maxfilesize * 2.5 : cfg.main.maxfilesize) / 1024; @@ -115,7 +115,7 @@ export default async bot => { await fs.promises.copyFile(`./tmp/${filename}`, `./public/b/${filename}`); await fs.promises.unlink(`./tmp/${filename}`).catch(_=>{}); - const insertq = (await sql("items").insert({ + await sql("items").insert({ src: e.photo ? "" : link, dest: filename, mime: mime, @@ -126,7 +126,8 @@ export default async bot => { usernetwork: e.network, stamp: ~~(new Date() / 1000), active: 1 - }))[0]; + }); + const insertq = (await sql('items').where('dest', filename).limit(1))[0].id; // generate thumbnail try { diff --git a/src/index.mjs b/src/index.mjs index 1228999..d797f6f 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -81,7 +81,7 @@ import flummpress from "flummpress"; req.session = user[0]; await sql("user_sessions") // log last action - .update("last_used", (Date.now() / 1e3)) + .update("last_used", ~~(Date.now() / 1e3)) .update("last_action", req.url.pathname) .update("browser", req.headers["user-agent"]) .where("id", user[0].sess_id);