diff --git a/backend/Dockerfile b/backend/Dockerfile deleted file mode 100644 index 76a7aeb..0000000 --- a/backend/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM node:20-alpine - -ENV NODE_ENV=production -WORKDIR /backend - -COPY package*.json ./ -RUN npm ci --omit=dev - -COPY . . - -EXPOSE 8002 -CMD ["npm", "start"] \ No newline at end of file diff --git a/backend/info.json b/backend/info.json deleted file mode 100644 index d8c809a..0000000 --- a/backend/info.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "backend-info": { - "version": "v2.0 (dev)" - }, - "frontend-info": { - "version": "v2.0 (dev)" - } -} \ No newline at end of file diff --git a/backend/package-lock.json b/backend/package-lock.json deleted file mode 100644 index 5ea46a4..0000000 --- a/backend/package-lock.json +++ /dev/null @@ -1,1072 +0,0 @@ -{ - "name": "backend", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "backend", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "cors": "^2.8.5", - "dotenv": "^17.2.1", - "ejs": "^3.1.10", - "express": "^5.1.0", - "jose": "^6.0.12", - "mysql2": "^3.14.3", - "nodemailer": "^7.0.6" - } - }, - "node_modules/accepts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", - "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", - "license": "MIT", - "dependencies": { - "mime-types": "^3.0.0", - "negotiator": "^1.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/async": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", - "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", - "license": "MIT" - }, - "node_modules/aws-ssl-profiles": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz", - "integrity": "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==", - "license": "MIT", - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "license": "MIT" - }, - "node_modules/body-parser": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", - "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", - "license": "MIT", - "dependencies": { - "bytes": "^3.1.2", - "content-type": "^1.0.5", - "debug": "^4.4.0", - "http-errors": "^2.0.0", - "iconv-lite": "^0.6.3", - "on-finished": "^2.4.1", - "qs": "^6.14.0", - "raw-body": "^3.0.0", - "type-is": "^2.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/call-bind-apply-helpers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", - "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/call-bound": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", - "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "get-intrinsic": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/content-disposition": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", - "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", - "license": "MIT", - "dependencies": { - "safe-buffer": "5.2.1" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/content-type": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", - "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", - "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie-signature": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", - "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", - "license": "MIT", - "engines": { - "node": ">=6.6.0" - } - }, - "node_modules/cors": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", - "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", - "license": "MIT", - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/debug": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", - "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/denque": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", - "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", - "license": "Apache-2.0", - "engines": { - "node": ">=0.10" - } - }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/dotenv": { - "version": "17.2.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.1.tgz", - "integrity": "sha512-kQhDYKZecqnM0fCnzI5eIv5L4cAe/iRI+HqMbO/hbRdTAeXDG+M9FjipUxNfbARuEg4iHIbhnhs78BCHNbSxEQ==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, - "node_modules/dunder-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", - "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "es-errors": "^1.3.0", - "gopd": "^1.2.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", - "license": "MIT" - }, - "node_modules/ejs": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", - "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", - "license": "Apache-2.0", - "dependencies": { - "jake": "^10.8.5" - }, - "bin": { - "ejs": "bin/cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/es-define-property": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", - "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "license": "MIT", - "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==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-object-atoms": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", - "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "license": "MIT" - }, - "node_modules/etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/express": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", - "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", - "license": "MIT", - "dependencies": { - "accepts": "^2.0.0", - "body-parser": "^2.2.0", - "content-disposition": "^1.0.0", - "content-type": "^1.0.5", - "cookie": "^0.7.1", - "cookie-signature": "^1.2.1", - "debug": "^4.4.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "finalhandler": "^2.1.0", - "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "merge-descriptors": "^2.0.0", - "mime-types": "^3.0.0", - "on-finished": "^2.4.1", - "once": "^1.4.0", - "parseurl": "^1.3.3", - "proxy-addr": "^2.0.7", - "qs": "^6.14.0", - "range-parser": "^1.2.1", - "router": "^2.2.0", - "send": "^1.1.0", - "serve-static": "^2.2.0", - "statuses": "^2.0.1", - "type-is": "^2.0.1", - "vary": "^1.1.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/filelist": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", - "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", - "license": "Apache-2.0", - "dependencies": { - "minimatch": "^5.0.1" - } - }, - "node_modules/finalhandler": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", - "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "on-finished": "^2.4.1", - "parseurl": "^1.3.3", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/forwarded": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fresh": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", - "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/generate-function": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", - "integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==", - "license": "MIT", - "dependencies": { - "is-property": "^1.0.2" - } - }, - "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "es-define-property": "^1.0.1", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", - "function-bind": "^1.1.2", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-symbols": "^1.1.0", - "hasown": "^2.0.2", - "math-intrinsics": "^1.1.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", - "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", - "license": "MIT", - "dependencies": { - "dunder-proto": "^1.0.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/gopd": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", - "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", - "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/http-errors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", - "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", - "license": "MIT", - "dependencies": { - "depd": "2.0.0", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "toidentifier": "1.0.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/http-errors/node_modules/statuses": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "license": "MIT", - "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==", - "license": "ISC" - }, - "node_modules/ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/is-promise": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", - "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", - "license": "MIT" - }, - "node_modules/is-property": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==", - "license": "MIT" - }, - "node_modules/jake": { - "version": "10.9.4", - "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.4.tgz", - "integrity": "sha512-wpHYzhxiVQL+IV05BLE2Xn34zW1S223hvjtqk0+gsPrwd/8JNLXJgZZM/iPFsYc1xyphF+6M6EvdE5E9MBGkDA==", - "license": "Apache-2.0", - "dependencies": { - "async": "^3.2.6", - "filelist": "^1.0.4", - "picocolors": "^1.1.1" - }, - "bin": { - "jake": "bin/cli.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/jose": { - "version": "6.0.12", - "resolved": "https://registry.npmjs.org/jose/-/jose-6.0.12.tgz", - "integrity": "sha512-T8xypXs8CpmiIi78k0E+Lk7T2zlK4zDyg+o1CZ4AkOHgDg98ogdP2BeZ61lTFKFyoEwJ9RgAgN+SdM3iPgNonQ==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/panva" - } - }, - "node_modules/long": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz", - "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==", - "license": "Apache-2.0" - }, - "node_modules/lru-cache": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", - "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/lru.min": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.2.tgz", - "integrity": "sha512-Nv9KddBcQSlQopmBHXSsZVY5xsdlZkdH/Iey0BlcBYggMd4two7cZnKOK9vmy3nY0O5RGH99z1PCeTpPqszUYg==", - "license": "MIT", - "engines": { - "bun": ">=1.0.0", - "deno": ">=1.30.0", - "node": ">=8.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wellwelwel" - } - }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/media-typer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", - "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/merge-descriptors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", - "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mime-db": { - "version": "1.54.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", - "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", - "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", - "license": "MIT", - "dependencies": { - "mime-db": "^1.54.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/mysql2": { - "version": "3.14.3", - "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.14.3.tgz", - "integrity": "sha512-fD6MLV8XJ1KiNFIF0bS7Msl8eZyhlTDCDl75ajU5SJtpdx9ZPEACulJcqJWr1Y8OYyxsFc4j3+nflpmhxCU5aQ==", - "license": "MIT", - "dependencies": { - "aws-ssl-profiles": "^1.1.1", - "denque": "^2.1.0", - "generate-function": "^2.3.1", - "iconv-lite": "^0.6.3", - "long": "^5.2.1", - "lru.min": "^1.0.0", - "named-placeholders": "^1.1.3", - "seq-queue": "^0.0.5", - "sqlstring": "^2.3.2" - }, - "engines": { - "node": ">= 8.0" - } - }, - "node_modules/named-placeholders": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.3.tgz", - "integrity": "sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w==", - "license": "MIT", - "dependencies": { - "lru-cache": "^7.14.1" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/negotiator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", - "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/nodemailer": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.6.tgz", - "integrity": "sha512-F44uVzgwo49xboqbFgBGkRaiMgtoBrBEWCVincJPK9+S9Adkzt/wXCLKbf7dxucmxfTI5gHGB+bEmdyzN6QKjw==", - "license": "MIT-0", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-inspect": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", - "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", - "license": "MIT", - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "license": "ISC", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/path-to-regexp": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", - "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", - "license": "MIT", - "engines": { - "node": ">=16" - } - }, - "node_modules/picocolors": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", - "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "license": "ISC" - }, - "node_modules/proxy-addr": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", - "license": "MIT", - "dependencies": { - "forwarded": "0.2.0", - "ipaddr.js": "1.9.1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/qs": { - "version": "6.14.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", - "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", - "license": "BSD-3-Clause", - "dependencies": { - "side-channel": "^1.1.0" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/raw-body": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.0.tgz", - "integrity": "sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g==", - "license": "MIT", - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.6.3", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/router": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", - "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "depd": "^2.0.0", - "is-promise": "^4.0.0", - "parseurl": "^1.3.3", - "path-to-regexp": "^8.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "license": "MIT" - }, - "node_modules/send": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", - "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", - "license": "MIT", - "dependencies": { - "debug": "^4.3.5", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "mime-types": "^3.0.1", - "ms": "^2.1.3", - "on-finished": "^2.4.1", - "range-parser": "^1.2.1", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/seq-queue": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz", - "integrity": "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q==" - }, - "node_modules/serve-static": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", - "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", - "license": "MIT", - "dependencies": { - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "parseurl": "^1.3.3", - "send": "^1.2.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "license": "ISC" - }, - "node_modules/side-channel": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", - "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.3", - "side-channel-list": "^1.0.0", - "side-channel-map": "^1.0.1", - "side-channel-weakmap": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-list": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", - "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-map": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", - "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-weakmap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", - "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3", - "side-channel-map": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/sqlstring": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.3.tgz", - "integrity": "sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/statuses": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", - "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "license": "MIT", - "engines": { - "node": ">=0.6" - } - }, - "node_modules/type-is": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", - "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", - "license": "MIT", - "dependencies": { - "content-type": "^1.0.5", - "media-typer": "^1.1.0", - "mime-types": "^3.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "license": "ISC" - } - } -} diff --git a/backend/package.json b/backend/package.json deleted file mode 100644 index 2215eb9..0000000 --- a/backend/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "backend", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "node server.js" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "cors": "^2.8.5", - "dotenv": "^17.2.1", - "ejs": "^3.1.10", - "express": "^5.1.0", - "jose": "^6.0.12", - "mysql2": "^3.14.3", - "nodemailer": "^7.0.6" - } -} diff --git a/backend/routes/api.js b/backend/routes/api.js deleted file mode 100644 index 6a09cba..0000000 --- a/backend/routes/api.js +++ /dev/null @@ -1,599 +0,0 @@ -import express from "express"; -import { - loginFunc, - getItemsFromDatabase, - getLoansFromDatabase, - getUserLoansFromDatabase, - deleteLoanFromDatabase, - getBorrowableItemsFromDatabase, - createLoanInDatabase, - onTake, - loginAdmin, - onReturn, - getAllUsers, - deleteUserID, - handleEdit, - createUser, - getAllLoans, - getAllItems, - deleteItemID, - createItem, - changeUserPassword, - changeUserPasswordFRONTEND, - changeInSafeStateV2, - updateItemByID, - getAllApiKeys, - createAPIentry, - deleteAPKey, - getLoanInfoWithID, - SETdeleteLoanFromDatabase, -} from "../services/database.js"; -import { authenticate, generateToken } from "../services/tokenService.js"; -const router = express.Router(); -import nodemailer from "nodemailer"; -import dotenv from "dotenv"; -dotenv.config(); - -// Nice HTML + text templates for the loan email -function buildLoanEmail({ user, items, startDate, endDate, createdDate }) { - const brand = process.env.MAIL_BRAND_COLOR || "#0ea5e9"; - const itemsList = - Array.isArray(items) && items.length - ? `` - : "N/A"; - - return ` - - - - - - - - - - - -
- Neue Ausleihe erstellt – Übersicht der Buchung. -
-
- - - - - - - - -
- -`; -} - -function buildLoanEmailText({ user, items, startDate, endDate, createdDate }) { - const itemsText = - Array.isArray(items) && items.length ? items.join(", ") : "N/A"; - return [ - "Neue Ausleihe erstellt", - "", - `Benutzer: ${user || "N/A"}`, - `Gegenstände: ${itemsText}`, - `Start: ${formatDateTime(startDate)}`, - `Ende: ${formatDateTime(endDate)}`, - `Erstellt am: ${formatDateTime(createdDate)}`, - ].join("\n"); -} - -function sendMailLoan(user, items, startDate, endDate, createdDate) { - const transporter = nodemailer.createTransport({ - host: process.env.MAIL_HOST, - port: process.env.MAIL_PORT, - secure: true, - auth: { - user: process.env.MAIL_USER, - pass: process.env.MAIL_PASSWORD, - }, - }); - - (async () => { - const info = await transporter.sendMail({ - from: '"Ausleihsystem" ', - to: process.env.MAIL_SENDEES, - subject: "Eine neue Ausleihe wurde erstellt!", - text: buildLoanEmailText({ - user, - items, - startDate, - endDate, - createdDate, - }), - html: buildLoanEmail({ user, items, startDate, endDate, createdDate }), - }); - - console.log("Message sent:", info.messageId); - })(); - console.log("sendMailLoan called"); -} - -const formatDateTime = (value) => { - if (value == null) return "N/A"; - - const toOut = (d) => { - if (!(d instanceof Date) || isNaN(d.getTime())) return "N/A"; - const dd = String(d.getDate()).padStart(2, "0"); - const mm = String(d.getMonth() + 1).padStart(2, "0"); - const yyyy = d.getFullYear(); - const hh = String(d.getHours()).padStart(2, "0"); - const mi = String(d.getMinutes()).padStart(2, "0"); - return `${dd}.${mm}.${yyyy} ${hh}:${mi} Uhr`; - }; - - if (value instanceof Date) return toOut(value); - if (typeof value === "number") return toOut(new Date(value)); - - const s = String(value).trim(); - - // Direct pattern: "YYYY-MM-DD[ T]HH:mm[:ss]" - const m = s.match(/^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})(?::\d{2})?/); - if (m) { - const [, y, M, d, h, min] = m; - return `${d}.${M}.${y} ${h}:${min} Uhr`; - } - - // ISO or other parseable formats - const dObj = new Date(s); - if (!isNaN(dObj.getTime())) return toOut(dObj); - - return "N/A"; -}; - -router.post("/login", async (req, res) => { - const result = await loginFunc(req.body.username, req.body.password); - if (result.success) { - const token = await generateToken({ - username: result.data.username, - role: result.data.role, - }); - res.status(200).json({ message: "Login successful", token }); - } else { - res.status(401).json({ message: "Invalid credentials" }); - } -}); - -router.get("/items", authenticate, async (req, res) => { - const result = await getItemsFromDatabase(req.user.role); - if (result.success) { - res.status(200).json(result.data); - } else { - res.status(500).json({ message: "Failed to fetch items" }); - } -}); - -router.get("/loans", authenticate, async (req, res) => { - const result = await getLoansFromDatabase(); - if (result.success) { - res.status(200).json(result.data); - } else { - res.status(500).json({ message: "Failed to fetch loans" }); - } -}); - -router.get("/userLoans", authenticate, async (req, res) => { - const result = await getUserLoansFromDatabase(req.user.username); - if (result.success) { - res.status(200).json(result.data); - } else { - res.status(500).json({ message: "Failed to fetch user loans" }); - } -}); - -router.delete("/deleteLoan/:id", authenticate, async (req, res) => { - const loanId = req.params.id; - const result = await deleteLoanFromDatabase(loanId); - if (result.success) { - res.status(200).json({ message: "Loan deleted successfully" }); - } else { - res.status(500).json({ message: "Failed to delete loan" }); - } -}); - -router.delete("/SETdeleteLoan/:id", authenticate, async (req, res) => { - const loanId = req.params.id; - const result = await SETdeleteLoanFromDatabase(loanId); - if (result.success) { - res.status(200).json({ message: "Loan deleted successfully" }); - } else { - res.status(500).json({ message: "Failed to delete loan" }); - } -}); - -router.post("/borrowableItems", authenticate, async (req, res) => { - const { startDate, endDate } = req.body || {}; - if (!startDate || !endDate) { - return res - .status(400) - .json({ message: "startDate and endDate are required" }); - } - - const result = await getBorrowableItemsFromDatabase( - startDate, - endDate, - req.user.role - ); - if (result.success) { - // return the array directly for consistency with /items - return res.status(200).json(result.data); - } else { - return res - .status(500) - .json({ message: "Failed to fetch borrowable items" }); - } -}); - -router.post("/takeLoan/:id", authenticate, async (req, res) => { - const loanId = req.params.id; - const result = await onTake(loanId); - if (result.success) { - res.status(200).json({ message: "Loan taken successfully" }); - } else { - res.status(500).json({ message: "Failed to take loan" }); - } -}); - -router.post("/returnLoan/:id", authenticate, async (req, res) => { - const loanId = req.params.id; - const result = await onReturn(loanId); - if (result.success) { - res.status(200).json({ message: "Loan returned successfully" }); - } else { - res.status(500).json({ message: "Failed to return loan" }); - } -}); - -router.post("/createLoan", authenticate, async (req, res) => { - try { - const { items, startDate, endDate } = req.body || {}; - - if (!Array.isArray(items) || items.length === 0) { - return res.status(400).json({ message: "Items array is required" }); - } - - // If dates are not provided, default to now .. +7 days - const start = - startDate ?? new Date().toISOString().slice(0, 19).replace("T", " "); - const end = - endDate ?? - new Date(Date.now() + 7 * 24 * 60 * 60 * 1000) - .toISOString() - .slice(0, 19) - .replace("T", " "); - - // Coerce item IDs to numbers and filter invalids - const itemIds = items - .map((v) => Number(v)) - .filter((n) => Number.isFinite(n)); - - if (itemIds.length === 0) { - return res.status(400).json({ message: "No valid item IDs provided" }); - } - - const result = await createLoanInDatabase( - req.user.username, - start, - end, - itemIds - ); - - if (result.success) { - const mailInfo = await getLoanInfoWithID(result.data.id); - console.log(mailInfo); - sendMailLoan( - mailInfo.data.username, - mailInfo.data.loaned_items_name, - mailInfo.data.start_date, - mailInfo.data.end_date, - mailInfo.data.created_at - ); - return res.status(201).json({ - message: "Loan created successfully", - loanId: result.data.id, - loanCode: result.data.loan_code, - }); - } - - if (result.code === "CONFLICT") { - return res - .status(409) - .json({ message: "Items not available in the selected period" }); - } - - if (result.code === "BAD_REQUEST") { - return res.status(400).json({ message: result.message }); - } - - return res.status(500).json({ message: "Failed to create loan" }); - } catch (err) { - console.error("createLoan error:", err); - return res.status(500).json({ message: "Failed to create loan" }); - } -}); - -router.post("/changePassword", authenticate, async (req, res) => { - const { oldPassword, newPassword } = req.body || {}; - const username = req.user.username; - const result = await changeUserPasswordFRONTEND( - username, - oldPassword, - newPassword - ); - if (result.success) { - res.status(200).json({ message: "Password changed successfully" }); - } else { - res.status(500).json({ message: "Failed to change password" }); - } -}); - -// Admin panel functions - -router.post("/loginAdmin", async (req, res) => { - const { username, password } = req.body || {}; - if (!username || !password) { - return res - .status(400) - .json({ message: "Username and password are required" }); - } - - const result = await loginAdmin(username, password); - if (result.success) { - const token = await generateToken({ - username: result.data.username, - role: result.data.role, - }); - - return res.status(200).json({ - message: "Login successful", - first_name: result.data.first_name, - token, - }); - } - - return res.status(401).json({ message: "Invalid credentials" }); -}); - -router.get("/allUsers", authenticate, async (req, res) => { - const result = await getAllUsers(); - if (result.success) { - return res.status(200).json(result.data); - } - return res.status(500).json({ message: "Failed to fetch users" }); -}); - -router.delete("/deleteUser/:id", authenticate, async (req, res) => { - const userId = req.params.id; - const result = await deleteUserID(userId); - if (result.success) { - return res.status(200).json({ message: "User deleted successfully" }); - } - return res.status(500).json({ message: "Failed to delete user" }); -}); - -router.get("/verifyToken", authenticate, async (req, res) => { - res.status(200).json({ message: "Token is valid", user: req.user }); -}); - -router.post("/editUser/:id", authenticate, async (req, res) => { - const userId = req.params.id; - const { username, role } = req.body || {}; - const result = await handleEdit(userId, username, role); - if (result.success) { - return res.status(200).json({ message: "User edited successfully" }); - } - return res.status(500).json({ message: "Failed to edit user" }); -}); - -router.post("/createUser", authenticate, async (req, res) => { - const { username, role, password } = req.body || {}; - const result = await createUser(username, role, password); - if (result.success) { - return res.status(201).json({ message: "User created successfully" }); - } - return res.status(500).json({ message: "Failed to create user" }); -}); - -router.get("/allLoans", authenticate, async (req, res) => { - const result = await getAllLoans(); - if (result.success) { - return res.status(200).json(result.data); - } - return res.status(500).json({ message: "Failed to fetch loans" }); -}); - -router.get("/allItems", authenticate, async (req, res) => { - const result = await getAllItems(); - if (result.success) { - return res.status(200).json(result.data); - } - return res.status(500).json({ message: "Failed to fetch items" }); -}); - -router.delete("/deleteItem/:id", authenticate, async (req, res) => { - const itemId = req.params.id; - const result = await deleteItemID(itemId); - if (result.success) { - return res.status(200).json({ message: "Item deleted successfully" }); - } - return res.status(500).json({ message: "Failed to delete item" }); -}); - -router.post("/createItem", authenticate, async (req, res) => { - const { item_name, can_borrow_role } = req.body || {}; - const result = await createItem(item_name, can_borrow_role); - if (result.success) { - return res.status(201).json({ message: "Item created successfully" }); - } - return res.status(500).json({ message: "Failed to create item" }); -}); - -router.post("/changePWadmin", authenticate, async (req, res) => { - const newPassword = req.body.newPassword; - if (!newPassword) { - return res.status(400).json({ message: "New password is required" }); - } - - const result = await changeUserPassword(req.body.username, newPassword); - if (result.success) { - return res.status(200).json({ message: "Password changed successfully" }); - } - return res.status(500).json({ message: "Failed to change password" }); -}); - -router.post("/updateItemByID", authenticate, async (req, res) => { - const role = req.body.can_borrow_role; - const itemId = req.body.itemId; - const item_name = req.body.item_name; - const result = await updateItemByID(itemId, item_name, role); - if (result.success) { - return res.status(200).json({ message: "Item updated successfully" }); - } - return res.status(500).json({ message: "Failed to update item" }); -}); - -router.put("/changeSafeState/:itemId", authenticate, async (req, res) => { - const itemId = req.params.itemId; - const result = await changeInSafeStateV2(itemId); - if (result.success) { - return res - .status(200) - .json({ message: "Item safe state updated successfully" }); - } - return res.status(500).json({ message: "Failed to update item safe state" }); -}); - -router.get("/apiKeys", authenticate, async (req, res) => { - const result = await getAllApiKeys(); - if (result.success) { - return res.status(200).json(result.data); - } - return res.status(500).json({ message: "Failed to fetch API keys" }); -}); - -router.delete("/deleteAPKey/:id", authenticate, async (req, res) => { - const apiKeyId = req.params.id; - const result = await deleteAPKey(apiKeyId); - if (result.success) { - return res.status(200).json({ message: "API key deleted successfully" }); - } - return res.status(500).json({ message: "Failed to delete API key" }); -}); - -router.post("/createAPIentry", authenticate, async (req, res) => { - const apiKey = req.body.apiKey; - const user = req.body.user; - if (!apiKey || !user) { - return res.status(400).json({ message: "API key and user are required" }); - } - - // Ensure apiKey is a number - const apiKeyNum = Number(apiKey); - if (!Number.isFinite(apiKeyNum)) { - return res.status(400).json({ message: "API key must be a number" }); - } - - const result = await createAPIentry(apiKeyNum, user); - if (result.success) { - return res.status(201).json({ message: "API key created successfully" }); - } - if (result.code === "DUPLICATE") { - return res.status(409).json({ message: "API key already exists" }); - } - return res.status(500).json({ message: "Failed to create API key" }); -}); - -router.get("/apiKeys/validate/:key", async (req, res) => { - try { - const rawKey = req.params.key; - const result = await getAllApiKeys(); - if (!result.success || !Array.isArray(result.data)) { - return res.status(500).json({ valid: false }); - } - - const isValid = result.data.some((entry) => { - const val = String( - entry?.key ?? entry?.apiKey ?? entry?.api_key ?? entry - ); - return val === String(rawKey); - }); - - return res.status(200).json({ valid: isValid }); - } catch (err) { - console.error("validate api key error:", err); - return res.status(500).json({ valid: false }); - } -}); - -export default router; diff --git a/backend/routes/apiV2.js b/backend/routes/apiV2.js deleted file mode 100644 index 5f1098b..0000000 --- a/backend/routes/apiV2.js +++ /dev/null @@ -1,133 +0,0 @@ -import express from "express"; -import dotenv from "dotenv"; -import { - getItemsFromDatabaseV2, - changeInSafeStateV2, - setTakeDateV2, - setReturnDateV2, - getLoanByCodeV2, - getAllLoansV2, - getAPIkey, -} from "../services/database.js"; - -dotenv.config(); -const router = express.Router(); - -async function validateAPIKey(apiKey) { - try { - if (!apiKey) return false; - const result = await getAPIkey(); - if (!result?.success || !Array.isArray(result.data)) return false; - return result.data.some((row) => String(row.apiKey) === String(apiKey)); - } catch (err) { - console.error("validateAPIKey error:", err); - return false; - } -} - -// Add a guard that returns Access Denied instead of hanging -const apiKeyGuard = async (req, res, next) => { - try { - const key = req.params.key; - if (!key) { - return res - .status(401) - .json({ message: "Access denied: missing API key" }); - } - const ok = await validateAPIKey(key); - if (!ok) { - return res - .status(401) - .json({ message: "Access denied: invalid API key" }); - } - next(); - } catch (e) { - console.error("apiKeyGuard error:", e); - res.status(500).json({ message: "Internal server error" }); - } -}; - -// Route for API to get ALL items from the database -router.get("/items/:key", apiKeyGuard, async (req, res) => { - const result = await getItemsFromDatabaseV2(); - if (result.success) { - res.status(200).json({ data: result.data }); - } else { - res.status(500).json({ message: "Failed to fetch items" }); - } -}); - -// Route for API to control the position of an item -router.post( - "/controlInSafe/:key/:itemId/:state", - apiKeyGuard, - async (req, res) => { - const itemId = req.params.itemId; - const state = req.params.state; - - if (state === "1" || state === "0") { - const result = await changeInSafeStateV2(itemId, state); - if (result.success) { - res.status(200).json({ data: result.data }); - } else { - res.status(500).json({ message: "Failed to update item state" }); - } - } else { - res.status(400).json({ message: "Invalid state value" }); - } - } -); - -// Route for API to get a loan by its code -router.get("/getLoanByCode/:key/:loan_code", apiKeyGuard, async (req, res) => { - const loan_code = req.params.loan_code; - const result = await getLoanByCodeV2(loan_code); - if (result.success) { - res.status(200).json({ data: result.data }); - } else { - res.status(404).json({ message: "Loan not found" }); - } -}); - -// Route for API to set the return date by the loan code -router.post("/setReturnDate/:key/:loan_code", apiKeyGuard, async (req, res) => { - const loanCode = req.params.loan_code; - const result = await setReturnDateV2(loanCode); - if (result.success) { - res.status(200).json({ data: result.data }); - } else { - res.status(500).json({ message: "Failed to set return date" }); - } -}); - -// Route for API to set the take away date by the loan code -router.post("/setTakeDate/:key/:loan_code", apiKeyGuard, async (req, res) => { - const loanCode = req.params.loan_code; - const result = await setTakeDateV2(loanCode); - if (result.success) { - res.status(200).json({ data: result.data }); - } else { - res.status(500).json({ message: "Failed to set take date" }); - } -}); - -// Route for API to get ALL loans from the database without sensitive info (only for landingpage) -router.get("/allLoans", async (req, res) => { - const result = await getAllLoansV2(); - if (result.success) { - return res.status(200).json(result.data); - } - return res.status(500).json({ message: "Failed to fetch loans" }); -}); - -// Route for API to get ALL items from the database (only for landingpage) -router.get("/allItems", async (req, res) => { - const result = await getItemsFromDatabaseV2(); - if (result.success) { - res.status(200).json(result.data); - } else { - res.status(500).json({ message: "Failed to fetch items" }); - } -}); - -export default router; diff --git a/backend/server.js b/backend/server.js deleted file mode 100644 index 1c673e2..0000000 --- a/backend/server.js +++ /dev/null @@ -1,37 +0,0 @@ -import express from "express"; -import cors from "cors"; -import env from "dotenv"; -import apiRouter from "./routes/api.js"; -import apiRouterV2 from "./routes/apiV2.js"; -env.config(); -const app = express(); -const port = 8002; -import serverInfo from "./info.json" assert { type: "json" } - -app.use(cors()); -// Increase body size limits to support large CSV JSON payloads -app.use(express.urlencoded({ extended: true, limit: "10mb" })); -app.set("view engine", "ejs"); -app.use(express.json({ limit: "10mb" })); - -app.use("/api", apiRouter); -app.use("/apiV2", apiRouterV2); - -app.get("/", (req, res) => { - res.render("index.ejs"); -}); - -app.get("/server-info", async (req, res) => { - res.status(200).json(serverInfo); -}); - -app.listen(port, () => { - console.log(`Server is running on port: ${port}`); -}); - -// error handling code -app.use((err, req, res, next) => { - // Log the error stack and send a generic error response - console.error(err.stack); - res.status(500).send("Something broke!"); -}); diff --git a/backend/services/database.js b/backend/services/database.js deleted file mode 100644 index 960432d..0000000 --- a/backend/services/database.js +++ /dev/null @@ -1,551 +0,0 @@ -import mysql from "mysql2"; -import dotenv from "dotenv"; -dotenv.config(); - -const pool = mysql - .createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - }) - .promise(); - -export const loginFunc = async (username, password) => { - const [result] = await pool.query( - "SELECT * FROM users WHERE username = ? AND password = ?", - [username, password] - ); - if (result.length > 0) return { success: true, data: result[0] }; - return { success: false }; -}; - -export const getItemsFromDatabaseV2 = async () => { - const [rows] = await pool.query("SELECT * FROM items;"); - if (rows.length > 0) { - return { success: true, data: rows }; - } - return { success: false }; -}; - -export const getLoanByCodeV2 = async (loan_code) => { - const [result] = await pool.query( - "SELECT * FROM loans WHERE loan_code = ?;", - [loan_code] - ); - if (result.length > 0) { - return { success: true, data: result[0] }; - } - return { success: false }; -}; - -export const changeInSafeStateV2 = async (itemId) => { - const [result] = await pool.query( - "UPDATE items SET in = NOT inSafe WHERE id = ?", - [itemId] - ); - if (result.affectedRows > 0) { - return { success: true }; - } - return { success: false }; -}; - -export const setReturnDateV2 = async (loanCode) => { - const [items] = await pool.query( - "SELECT loaned_items_id FROM loans WHERE loan_code = ?", - [loanCode] - ); - - if (items.length === 0) return { success: false }; - - const itemIds = Array.isArray(items[0].loaned_items_id) - ? items[0].loaned_items_id - : JSON.parse(items[0].loaned_items_id || "[]"); - - const [setItemStates] = await pool.query( - "UPDATE items SET inSafe = 1 WHERE id IN (?)", - [itemIds] - ); - - const [result] = await pool.query( - "UPDATE loans SET returned_date = NOW() WHERE loan_code = ?", - [loanCode] - ); - - if (result.affectedRows > 0 && setItemStates.affectedRows > 0) { - return { success: true }; - } - return { success: false }; -}; - -export const setTakeDateV2 = async (loanCode) => { - const [items] = await pool.query( - "SELECT loaned_items_id FROM loans WHERE loan_code = ?", - [loanCode] - ); - - if (items.length === 0) return { success: false }; - - const itemIds = Array.isArray(items[0].loaned_items_id) - ? items[0].loaned_items_id - : JSON.parse(items[0].loaned_items_id || "[]"); - - const [setItemStates] = await pool.query( - "UPDATE items SET inSafe = 0 WHERE id IN (?)", - [itemIds] - ); - - const [result] = await pool.query( - "UPDATE loans SET take_date = NOW() WHERE loan_code = ?", - [loanCode] - ); - - if (result.affectedRows > 0 && setItemStates.affectedRows > 0) { - return { success: true }; - } - return { success: false }; -}; - -export const getItemsFromDatabase = async (role) => { - const sql = - role == 0 - ? "SELECT * FROM items;" - : "SELECT * FROM items WHERE can_borrow_role >= ?"; - const params = role == 0 ? [] : [role]; - - const [rows] = await pool.query(sql, params); - if (rows.length > 0) { - return { success: true, data: rows }; - } - return { success: false }; -}; - -export const getLoansFromDatabase = async () => { - const [rows] = await pool.query("SELECT * FROM loans;"); - return { success: true, data: rows.length > 0 ? rows : null }; -}; - -export const getUserLoansFromDatabase = async (username) => { - const [result] = await pool.query( - "SELECT * FROM loans WHERE username = ? AND deleted = 0;", - [username] - ); - if (result.length > 0) { - return { success: true, data: result }; - } else if (result.length == 0) { - return { success: true, data: "No loans found for this user" }; - } else { - return { success: false }; - } -}; - -export const deleteLoanFromDatabase = async (loanId) => { - const [result] = await pool.query("DELETE FROM loans WHERE id = ?;", [ - loanId, - ]); - if (result.affectedRows > 0) { - return { success: true }; - } else { - return { success: false }; - } -}; - -export const SETdeleteLoanFromDatabase = async (loanId) => { - const [result] = await pool.query( - "UPDATE loans SET deleted = 1 WHERE id = ?;", - [loanId] - ); - if (result.affectedRows > 0) { - return { success: true }; - } else { - return { success: false }; - } -}; - -export const getBorrowableItemsFromDatabase = async ( - startDate, - endDate, - role = 0 -) => { - // Overlap if: loan.start < end AND effective_end > start - // effective_end is returned_date if set, otherwise end_date - const hasRoleFilter = Number(role) > 0; - - const sql = ` - SELECT i.* - FROM items i - WHERE ${hasRoleFilter ? "i.can_borrow_role >= ? AND " : ""}NOT EXISTS ( - SELECT 1 - FROM loans l - JOIN JSON_TABLE(l.loaned_items_id, '$[*]' COLUMNS (item_id INT PATH '$')) jt - WHERE jt.item_id = i.id - AND l.deleted = 0 - AND l.start_date < ? - AND COALESCE(l.returned_date, l.end_date) > ? - ); - `; - - const params = hasRoleFilter - ? [role, endDate, startDate] - : [endDate, startDate]; - - const [rows] = await pool.query(sql, params); - if (rows.length > 0) { - return { success: true, data: rows }; - } - return { success: false }; -}; - -export const getLoanInfoWithID = async (loanId) => { - const [rows] = await pool.query("SELECT * FROM loans WHERE id = ?;", [ - loanId, - ]); - if (rows.length > 0) { - return { success: true, data: rows[0] }; - } - return { success: false }; -}; - -export const createLoanInDatabase = async ( - username, - startDate, - endDate, - itemIds -) => { - if (!username) - return { success: false, code: "BAD_REQUEST", message: "Missing username" }; - if (!Array.isArray(itemIds) || itemIds.length === 0) - return { - success: false, - code: "BAD_REQUEST", - message: "No items provided", - }; - if (!startDate || !endDate) - return { success: false, code: "BAD_REQUEST", message: "Missing dates" }; - - const start = new Date(startDate); - const end = new Date(endDate); - if ( - !(start instanceof Date) || - isNaN(start.getTime()) || - !(end instanceof Date) || - isNaN(end.getTime()) || - start >= end - ) { - return { - success: false, - code: "BAD_REQUEST", - message: "Invalid date range", - }; - } - - const conn = await pool.getConnection(); - try { - await conn.beginTransaction(); - - // Ensure all items exist and collect names - const [itemsRows] = await conn.query( - "SELECT id, item_name FROM items WHERE id IN (?)", - [itemIds] - ); - if (!itemsRows || itemsRows.length !== itemIds.length) { - await conn.rollback(); - return { - success: false, - code: "BAD_REQUEST", - message: "One or more items not found", - }; - } - const itemNames = itemIds - .map( - (id) => itemsRows.find((r) => Number(r.id) === Number(id))?.item_name - ) - .filter(Boolean); - - // Check availability (no overlap with existing loans) - const [confRows] = await conn.query( - ` - SELECT COUNT(*) AS conflicts - FROM loans l - JOIN JSON_TABLE(l.loaned_items_id, '$[*]' COLUMNS (item_id INT PATH '$')) jt - ON TRUE - WHERE jt.item_id IN (?) - AND l.deleted = 0 - AND l.start_date < ? - AND COALESCE(l.returned_date, l.end_date) > ? - `, - [itemIds, end, start] - ); - if (confRows?.[0]?.conflicts > 0) { - await conn.rollback(); - return { - success: false, - code: "CONFLICT", - message: "One or more items are not available in the selected period", - }; - } - - // Generate unique loan_code (retry a few times) - let loanCode = null; - for (let i = 0; i < 6; i++) { - const candidate = Math.floor(100000 + Math.random() * 899999); // 6 digits - const [exists] = await conn.query( - "SELECT 1 FROM loans WHERE loan_code = ? LIMIT 1", - [candidate] - ); - if (exists.length === 0) { - loanCode = candidate; - break; - } - } - if (!loanCode) { - await conn.rollback(); - return { - success: false, - code: "SERVER_ERROR", - message: "Failed to generate unique loan code", - }; - } - - // Insert loan - const [insertRes] = await conn.query( - ` - INSERT INTO loans (username, loan_code, start_date, end_date, loaned_items_id, loaned_items_name) - VALUES (?, ?, ?, ?, CAST(? AS JSON), CAST(? AS JSON)) - `, - [ - username, - loanCode, - // Use DATETIME/TIMESTAMP friendly format - new Date(start).toISOString().slice(0, 19).replace("T", " "), - new Date(end).toISOString().slice(0, 19).replace("T", " "), - JSON.stringify(itemIds.map((n) => Number(n))), - JSON.stringify(itemNames), - ] - ); - - await conn.commit(); - return { - success: true, - data: { - id: insertRes.insertId, - loan_code: loanCode, - username, - start_date: start, - end_date: end, - items: itemIds, - item_names: itemNames, - }, - }; - } catch (err) { - await conn.rollback(); - console.error("createLoanInDatabase error:", err); - return { - success: false, - code: "SERVER_ERROR", - message: "Failed to create loan", - }; - } finally { - conn.release(); - } -}; - -// These functions are only temporary, and will be deleted when the full bin is set up. -export const onTake = async (loanId) => { - const [items] = await pool.query( - "SELECT loaned_items_id FROM loans WHERE id = ?", - [loanId] - ); - - if (items.length === 0) return { success: false }; - - const itemIds = Array.isArray(items[0].loaned_items_id) - ? items[0].loaned_items_id - : JSON.parse(items[0].loaned_items_id || "[]"); - - const [setItemStates] = await pool.query( - "UPDATE items SET inSafe = 0 WHERE id IN (?)", - [itemIds] - ); - - const [result] = await pool.query( - "UPDATE loans SET take_date = NOW() WHERE id = ?", - [loanId] - ); - - if (result.affectedRows > 0 && setItemStates.affectedRows > 0) { - return { success: true }; - } - return { success: false }; -}; - -export const onReturn = async (loanId) => { - const [items] = await pool.query( - "SELECT loaned_items_id FROM loans WHERE id = ?", - [loanId] - ); - - if (items.length === 0) return { success: false }; - - const itemIds = Array.isArray(items[0].loaned_items_id) - ? items[0].loaned_items_id - : JSON.parse(items[0].loaned_items_id || "[]"); - - const [setItemStates] = await pool.query( - "UPDATE items SET inSafe = 1 WHERE id IN (?)", - [itemIds] - ); - - const [result] = await pool.query( - "UPDATE loans SET returned_date = NOW() WHERE id = ?", - [loanId] - ); - - if (result.affectedRows > 0 && setItemStates.affectedRows > 0) { - return { success: true }; - } - return { success: false }; -}; -// Temporary functions end here. - -export const loginAdmin = async (username, password) => { - const [result] = await pool.query( - "SELECT * FROM admins WHERE username = ? AND password = ?", - [username, password] - ); - if (result.length > 0) return { success: true, data: result[0] }; - return { success: false }; -}; - -export const getAllUsers = async () => { - const [result] = await pool.query( - "SELECT id, username, role, entry_created_at FROM users" - ); - if (result.length > 0) return { success: true, data: result }; - return { success: false }; -}; - -export const deleteUserID = async (userId) => { - const [result] = await pool.query("DELETE FROM users WHERE id = ?", [userId]); - if (result.affectedRows > 0) return { success: true }; - return { success: false }; -}; - -export const handleEdit = async (userId, username, role) => { - const [result] = await pool.query( - "UPDATE users SET username = ?, role = ? WHERE id = ?", - [username, role, userId] - ); - if (result.affectedRows > 0) return { success: true }; - return { success: false }; -}; - -export const createUser = async (username, role, password) => { - const [result] = await pool.query( - "INSERT INTO users (username, role, password) VALUES (?, ?, ?)", - [username, role, password] - ); - if (result.affectedRows > 0) return { success: true }; - return { success: false }; -}; - -export const getAllLoans = async () => { - const [result] = await pool.query("SELECT * FROM loans"); - if (result.length > 0) return { success: true, data: result }; - return { success: false }; -}; - -export const getAllItems = async () => { - const [result] = await pool.query("SELECT * FROM items"); - if (result.length > 0) return { success: true, data: result }; - return { success: false }; -}; - -export const deleteItemID = async (itemId) => { - const [result] = await pool.query("DELETE FROM items WHERE id = ?", [itemId]); - if (result.affectedRows > 0) return { success: true }; - return { success: false }; -}; - -export const createItem = async (item_name, can_borrow_role) => { - const [result] = await pool.query( - "INSERT INTO items (item_name, can_borrow_role) VALUES (?, ?)", - [item_name, can_borrow_role] - ); - if (result.affectedRows > 0) return { success: true }; - return { success: false }; -}; - -export const changeUserPassword = async (username, newPassword) => { - const [result] = await pool.query( - "UPDATE users SET password = ? WHERE username = ?", - [newPassword, username] - ); - if (result.affectedRows > 0) return { success: true }; - return { success: false }; -}; - -export const changeUserPasswordFRONTEND = async ( - username, - oldPassword, - newPassword -) => { - const [result] = await pool.query( - "UPDATE users SET password = ? WHERE username = ? AND password = ?", - [newPassword, username, oldPassword] - ); - if (result.affectedRows > 0) return { success: true }; - return { success: false }; -}; - -export const updateItemByID = async (itemId, item_name, can_borrow_role) => { - const [result] = await pool.query( - "UPDATE items SET item_name = ?, can_borrow_role = ? WHERE id = ?", - [item_name, can_borrow_role, itemId] - ); - if (result.affectedRows > 0) return { success: true }; - return { success: false }; -}; - -export const getAllLoansV2 = async () => { - const [rows] = await pool.query( - "SELECT id, username, start_date, end_date, loaned_items_name, returned_date, take_date FROM loans" - ); - if (rows.length > 0) { - return { success: true, data: rows }; - } - return { success: false }; -}; - -export const getAllApiKeys = async () => { - const [rows] = await pool.query("SELECT * FROM apiKeys"); - if (rows.length > 0) { - return { success: true, data: rows }; - } - return { success: false }; -}; - -export const createAPIentry = async (apiKey, user) => { - const [result] = await pool.query( - "INSERT INTO apiKeys (apiKey, user) VALUES (?, ?)", - [apiKey, user] - ); - if (result.affectedRows > 0) return { success: true }; - return { success: false }; -}; - -export const deleteAPKey = async (apiKeyId) => { - const [result] = await pool.query("DELETE FROM apiKeys WHERE id = ?", [ - apiKeyId, - ]); - if (result.affectedRows > 0) return { success: true }; - return { success: false }; -}; - -export const getAPIkey = async () => { - const [rows] = await pool.query("SELECT apiKey FROM apiKeys"); - if (rows.length > 0) { - return { success: true, data: rows }; - } - return { success: false }; -}; diff --git a/backend/services/tokenService.js b/backend/services/tokenService.js deleted file mode 100644 index 6d39377..0000000 --- a/backend/services/tokenService.js +++ /dev/null @@ -1,25 +0,0 @@ -import { SignJWT, jwtVerify } from "jose"; -import env from "dotenv"; -env.config(); -const secret = new TextEncoder().encode(process.env.SECRET_KEY); - -export async function generateToken(payload) { - const newToken = await new SignJWT(payload) - .setProtectedHeader({ alg: "HS256" }) - .setIssuedAt() - .setExpirationTime("2h") // Token valid for 2 hours - .sign(secret); - return newToken; -} - -export async function authenticate(req, res, next) { - const authHeader = req.headers["authorization"]; - const token = authHeader && authHeader.split(" ")[1]; // Bearer - - if (token == null) return res.sendStatus(401); // No token present - - const { payload } = await jwtVerify(token, secret); - req.user = payload; - - next(); -} diff --git a/backend/views/index.ejs b/backend/views/index.ejs deleted file mode 100644 index a6848b3..0000000 --- a/backend/views/index.ejs +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - backend - - - backend - - \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c20ef03..90ab08c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,26 +13,6 @@ services: # - "8003:80" # restart: unless-stopped - #backend: - # container_name: borrow_system-backend - # build: ./backend - # ports: - # - "8002:8002" - # environment: - # NODE_ENV: production - # DB_HOST: mysql - # DB_USER: root - # DB_PASSWORD: ${DB_PASSWORD} - # DB_NAME: borrow_system - # depends_on: - # - mysql - # restart: unless-stopped - # healthcheck: - # test: ["CMD", "wget", "-qO-", "http://localhost:8002/server-info"] - # interval: 30s - # timeout: 5s - # retries: 3 - backend_v2: container_name: borrow_system-backend_v2 build: ./backendV2 @@ -48,20 +28,6 @@ services: - mysql_v2 restart: unless-stopped - # mysql: - # container_name: borrow_system-mysql - # image: mysql:8.0 - # restart: unless-stopped - # environment: - # MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} - # MYSQL_DATABASE: borrow_system - # TZ: Europe/Berlin - # volumes: - # - mysql-data:/var/lib/mysql - # - ./mysql-timezone.cnf:/etc/mysql/conf.d/timezone.cnf:ro - # ports: - # - "3309:3306" - mysql_v2: container_name: borrow_system-mysql-v2 image: mysql:8.0