diff --git a/.gitignore b/.gitignore index 6a7d6d8..fe94852 100644 --- a/.gitignore +++ b/.gitignore @@ -127,4 +127,7 @@ dist .yarn/unplugged .yarn/build-state.yml .yarn/install-state.gz -.pnp.* \ No newline at end of file +.pnp.* + +.env +/dist \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e9b47cd..f8d1c91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,11 +9,23 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "express": "^4.21.2" + "@prisma/client": "^6.0.1", + "@types/cors": "^2.8.17", + "@types/jsonwebtoken": "^9.0.7", + "bcrypt": "^5.1.1", + "cors": "^2.8.5", + "dotenv": "^16.4.7", + "express": "^4.21.2", + "jsonwebtoken": "^9.0.2", + "mongoose": "^8.8.4", + "zod": "^3.23.8" }, "devDependencies": { - "@types/express": "^5.0.0", + "@types/bcrypt": "^5.0.2", + "@types/express": "^4.17.21", + "@types/node": "^22.10.1", "nodemon": "^3.1.7", + "prisma": "^6.0.1", "ts-node": "^10.9.2", "typescript": "^5.7.2" } @@ -59,6 +71,103 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@mapbox/node-pre-gyp": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz", + "integrity": "sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==", + "license": "BSD-3-Clause", + "dependencies": { + "detect-libc": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "make-dir": "^3.1.0", + "node-fetch": "^2.6.7", + "nopt": "^5.0.0", + "npmlog": "^5.0.1", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.11" + }, + "bin": { + "node-pre-gyp": "bin/node-pre-gyp" + } + }, + "node_modules/@mongodb-js/saslprep": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.9.tgz", + "integrity": "sha512-tVkljjeEaAhCqTzajSdgbQ6gE6f3oneVwa3iXR6csiEwXXOFsiC6Uh9iAjAhXPtqa/XMDHWjjeNH/77m/Yq2dw==", + "license": "MIT", + "dependencies": { + "sparse-bitfield": "^3.0.3" + } + }, + "node_modules/@prisma/client": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.0.1.tgz", + "integrity": "sha512-60w7kL6bUxz7M6Gs/V+OWMhwy94FshpngVmOY05TmGD0Lhk+Ac0ZgtjlL6Wll9TD4G03t4Sq1wZekNVy+Xdlbg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "peerDependencies": { + "prisma": "*" + }, + "peerDependenciesMeta": { + "prisma": { + "optional": true + } + } + }, + "node_modules/@prisma/debug": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.0.1.tgz", + "integrity": "sha512-jQylgSOf7ibTVxqBacnAlVGvek6fQxJIYCQOeX2KexsfypNzXjJQSS2o5s+Mjj2Np93iSOQUaw6TvPj8syhG4w==", + "devOptional": true, + "license": "Apache-2.0" + }, + "node_modules/@prisma/engines": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.0.1.tgz", + "integrity": "sha512-4hxzI+YQIR2uuDyVsDooFZGu5AtixbvM2psp+iayDZ4hRrAHo/YwgA17N23UWq7G6gRu18NvuNMb48qjP3DPQw==", + "devOptional": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "6.0.1", + "@prisma/engines-version": "5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e", + "@prisma/fetch-engine": "6.0.1", + "@prisma/get-platform": "6.0.1" + } + }, + "node_modules/@prisma/engines-version": { + "version": "5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e.tgz", + "integrity": "sha512-JmIds0Q2/vsOmnuTJYxY4LE+sajqjYKhLtdOT6y4imojqv5d/aeVEfbBGC74t8Be1uSp0OP8lxIj2OqoKbLsfQ==", + "devOptional": true, + "license": "Apache-2.0" + }, + "node_modules/@prisma/fetch-engine": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.0.1.tgz", + "integrity": "sha512-T36bWFVGeGYYSyYOj9d+O9G3sBC+pAyMC+jc45iSL63/Haq1GrYjQPgPMxrEj9m739taXrupoysRedQ+VyvM/Q==", + "devOptional": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "6.0.1", + "@prisma/engines-version": "5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e", + "@prisma/get-platform": "6.0.1" + } + }, + "node_modules/@prisma/get-platform": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.0.1.tgz", + "integrity": "sha512-zspC9vlxAqx4E6epMPMLLBMED2VD8axDe8sPnquZ8GOsn6tiacWK0oxrGK4UAHYzYUVuMVUApJbdXB2dFpLhvg==", + "devOptional": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "6.0.1" + } + }, "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", @@ -87,6 +196,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/bcrypt": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@types/bcrypt/-/bcrypt-5.0.2.tgz", + "integrity": "sha512-6atioO8Y75fNcbmj0G7UjI9lXN2pQ/IGJ2FWT4a/btd0Lk9lQalHLKhkgKVZ3r+spnmWUKfbMi1GEe9wyHQfNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/body-parser": { "version": "1.19.5", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", @@ -108,23 +227,32 @@ "@types/node": "*" } }, + "node_modules/@types/cors": { + "version": "2.8.17", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", + "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/express": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.0.tgz", - "integrity": "sha512-DvZriSMehGHL1ZNLzi6MidnsDhUZM/x2pRdDIKdwbUNqqwHxMlRdkxtn6/EPKyqKpHqTl/4nRZsRNLpZxZRpPQ==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", + "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==", "dev": true, "license": "MIT", "dependencies": { "@types/body-parser": "*", - "@types/express-serve-static-core": "^5.0.0", + "@types/express-serve-static-core": "^4.17.33", "@types/qs": "*", "@types/serve-static": "*" } }, "node_modules/@types/express-serve-static-core": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.0.2.tgz", - "integrity": "sha512-vluaspfvWEtE4vcSDlKRNer52DvOGrB2xv6diXy6UKyKW0lqZiWHGNApSyxOv+8DE5Z27IzVvE7hNkxg7EXIcg==", + "version": "4.19.6", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.6.tgz", + "integrity": "sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==", "dev": true, "license": "MIT", "dependencies": { @@ -141,6 +269,15 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/jsonwebtoken": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.7.tgz", + "integrity": "sha512-ugo316mmTYBl2g81zDFnZ7cfxlut3o+/EQdaP7J8QN2kY6lJ22hmQYCK5EHcJHbrW+dkCGSCPgbG8JtYj6qSrg==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/mime": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", @@ -152,7 +289,6 @@ "version": "22.10.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.1.tgz", "integrity": "sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==", - "dev": true, "license": "MIT", "dependencies": { "undici-types": "~6.20.0" @@ -195,6 +331,27 @@ "@types/send": "*" } }, + "node_modules/@types/webidl-conversions": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", + "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==", + "license": "MIT" + }, + "node_modules/@types/whatwg-url": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", + "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", + "license": "MIT", + "dependencies": { + "@types/webidl-conversions": "*" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "license": "ISC" + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -234,6 +391,50 @@ "node": ">=0.4.0" } }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/agent-base/node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/agent-base/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/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -248,6 +449,26 @@ "node": ">= 8" } }, + "node_modules/aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "license": "ISC" + }, + "node_modules/are-we-there-yet": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", + "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "deprecated": "This package is no longer supported.", + "license": "ISC", + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -265,9 +486,22 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, "license": "MIT" }, + "node_modules/bcrypt": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.1.tgz", + "integrity": "sha512-AGBHOG5hPYZ5Xl9KXzU5iKq9516yEmvCKDg3ecP5kX2aB6UqTeXZxk2ELnDgDm6BQSMlLt9rDB4LoSMx0rYwww==", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "@mapbox/node-pre-gyp": "^1.0.11", + "node-addon-api": "^5.0.0" + }, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/binary-extensions": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", @@ -309,7 +543,6 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", @@ -329,6 +562,21 @@ "node": ">=8" } }, + "node_modules/bson": { + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.1.tgz", + "integrity": "sha512-P92xmHDQjSKPLHqFxefqMxASNq/aWJMEZugpCjf+AF/pgcUpMMQCg7t7+ewko0/u8AapvF3luf/FoehddEK+sA==", + "license": "Apache-2.0", + "engines": { + "node": ">=16.20.1" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -394,13 +642,36 @@ "fsevents": "~2.3.2" } }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "license": "ISC", + "bin": { + "color-support": "bin.js" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true, "license": "MIT" }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==", + "license": "ISC" + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -437,6 +708,19 @@ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", "license": "MIT" }, + "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/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -470,6 +754,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", + "license": "MIT" + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -489,6 +779,15 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/detect-libc": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, "node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -499,6 +798,18 @@ "node": ">=0.3.1" } }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/dunder-proto": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.0.tgz", @@ -513,12 +824,27 @@ "node": ">= 0.4" } }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "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/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, "node_modules/encodeurl": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", @@ -656,6 +982,36 @@ "node": ">= 0.6" } }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "license": "ISC", + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs-minipass/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "license": "ISC" + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -680,6 +1036,27 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/gauge": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", + "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", + "deprecated": "This package is no longer supported.", + "license": "ISC", + "dependencies": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.2", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.1", + "object-assign": "^4.1.1", + "signal-exit": "^3.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.2" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/get-intrinsic": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.5.tgz", @@ -702,6 +1079,27 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -761,6 +1159,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==", + "license": "ISC" + }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -789,6 +1193,42 @@ "node": ">= 0.8" } }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/https-proxy-agent/node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/https-proxy-agent/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/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -808,6 +1248,17 @@ "dev": true, "license": "ISC" }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -846,6 +1297,15 @@ "node": ">=0.10.0" } }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -869,23 +1329,153 @@ "node": ">=0.12.0" } }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true, - "license": "ISC" - }, - "node_modules/media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "node_modules/jsonwebtoken": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", "license": "MIT", + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, "engines": { - "node": ">= 0.6" + "node": ">=12", + "npm": ">=6" } }, - "node_modules/merge-descriptors": { + "node_modules/jsonwebtoken/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/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "license": "MIT", + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/kareem": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.6.3.tgz", + "integrity": "sha512-C3iHfuGUXK2u8/ipq9LfjFfXFxAZMQJJq7vLS45r3D9Y2xQ/m4S8zaR4zMLFWh9AsNPXmcFfUDhTEO8UIC/V6Q==", + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "license": "MIT", + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true, + "license": "ISC" + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "license": "MIT" + }, + "node_modules/merge-descriptors": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", @@ -940,7 +1530,6 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" @@ -949,6 +1538,180 @@ "node": "*" } }, + "node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "license": "ISC", + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "license": "MIT", + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minizlib/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mongodb": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.10.0.tgz", + "integrity": "sha512-gP9vduuYWb9ZkDM546M+MP2qKVk5ZG2wPF63OvSRuUbqCR+11ZCAE1mOfllhlAG0wcoJY5yDL/rV3OmYEwXIzg==", + "license": "Apache-2.0", + "dependencies": { + "@mongodb-js/saslprep": "^1.1.5", + "bson": "^6.7.0", + "mongodb-connection-string-url": "^3.0.0" + }, + "engines": { + "node": ">=16.20.1" + }, + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.188.0", + "@mongodb-js/zstd": "^1.1.0", + "gcp-metadata": "^5.2.0", + "kerberos": "^2.0.1", + "mongodb-client-encryption": ">=6.0.0 <7", + "snappy": "^7.2.2", + "socks": "^2.7.1" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "gcp-metadata": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + }, + "socks": { + "optional": true + } + } + }, + "node_modules/mongodb-connection-string-url": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.1.tgz", + "integrity": "sha512-XqMGwRX0Lgn05TDB4PyG2h2kKO/FfWJyCzYQbIhXUxz7ETt0I/FqHjUeqj37irJ+Dl1ZtU82uYyj14u2XsZKfg==", + "license": "Apache-2.0", + "dependencies": { + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^13.0.0" + } + }, + "node_modules/mongoose": { + "version": "8.8.4", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.8.4.tgz", + "integrity": "sha512-yJbn695qCsqDO+xyPII29x2R7flzXhxCDv09mMZPSGllf0sm4jKw3E9s9uvQ9hjO6bL2xjU8KKowYqcY9eSTMQ==", + "license": "MIT", + "dependencies": { + "bson": "^6.7.0", + "kareem": "2.6.3", + "mongodb": "~6.10.0", + "mpath": "0.9.0", + "mquery": "5.0.0", + "ms": "2.1.3", + "sift": "17.1.3" + }, + "engines": { + "node": ">=16.20.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mongoose" + } + }, + "node_modules/mongoose/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/mpath": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", + "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", + "license": "MIT", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mquery": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz", + "integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==", + "license": "MIT", + "dependencies": { + "debug": "4.x" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/mquery/node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mquery/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/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -964,6 +1727,54 @@ "node": ">= 0.6" } }, + "node_modules/node-addon-api": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", + "integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==", + "license": "MIT" + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-fetch/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/node-fetch/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/node-fetch/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/nodemon": { "version": "3.1.7", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz", @@ -1018,6 +1829,21 @@ "dev": true, "license": "MIT" }, + "node_modules/nopt": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", + "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", + "license": "ISC", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -1028,6 +1854,28 @@ "node": ">=0.10.0" } }, + "node_modules/npmlog": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", + "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", + "deprecated": "This package is no longer supported.", + "license": "ISC", + "dependencies": { + "are-we-there-yet": "^2.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^3.0.0", + "set-blocking": "^2.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.3", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", @@ -1052,6 +1900,15 @@ "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", @@ -1061,6 +1918,15 @@ "node": ">= 0.8" } }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/path-to-regexp": { "version": "0.1.12", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", @@ -1080,6 +1946,26 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/prisma": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.0.1.tgz", + "integrity": "sha512-CaMNFHkf+DDq8zq3X/JJsQ4Koy7dyWwwtOKibkT/Am9j/tDxcfbg7+lB1Dzhx18G/+RQCMgjPYB61bhRqteNBQ==", + "devOptional": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/engines": "6.0.1" + }, + "bin": { + "prisma": "build/index.js" + }, + "engines": { + "node": ">=18.18" + }, + "optionalDependencies": { + "fsevents": "2.3.3" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -1100,6 +1986,15 @@ "dev": true, "license": "MIT" }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/qs": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", @@ -1139,6 +2034,20 @@ "node": ">= 0.8" } }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -1152,6 +2061,22 @@ "node": ">=8.10.0" } }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", + "license": "ISC", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -1182,7 +2107,6 @@ "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", - "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -1245,6 +2169,12 @@ "node": ">= 0.8.0" } }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "license": "ISC" + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -1286,6 +2216,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/sift": { + "version": "17.1.3", + "resolved": "https://registry.npmjs.org/sift/-/sift-17.1.3.tgz", + "integrity": "sha512-Rtlj66/b0ICeFzYTuNvX/EF1igRbbnGSvEyT79McoZa/DeGhMyC5pWKOEsZKnpkqtSeovd5FL/bjHWC3CIIvCQ==", + "license": "MIT" + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "license": "ISC" + }, "node_modules/simple-update-notifier": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", @@ -1299,6 +2241,15 @@ "node": ">=10" } }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "license": "MIT", + "dependencies": { + "memory-pager": "^1.0.2" + } + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -1308,6 +2259,41 @@ "node": ">= 0.8" } }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -1321,6 +2307,23 @@ "node": ">=4" } }, + "node_modules/tar": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", + "license": "ISC", + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -1353,6 +2356,18 @@ "nodetouch": "bin/nodetouch.js" } }, + "node_modules/tr46": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz", + "integrity": "sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==", + "license": "MIT", + "dependencies": { + "punycode": "^2.3.0" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", @@ -1435,7 +2450,6 @@ "version": "6.20.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", - "dev": true, "license": "MIT" }, "node_modules/unpipe": { @@ -1447,6 +2461,12 @@ "node": ">= 0.8" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -1472,6 +2492,49 @@ "node": ">= 0.8" } }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-13.0.0.tgz", + "integrity": "sha512-9WWbymnqj57+XEuqADHrCJ2eSXzn8WXIW/YSGaZtb2WKAInQ6CHfaUUcTyyver0p8BDg5StLQq8h1vtZuwmOig==", + "license": "MIT", + "dependencies": { + "tr46": "^4.1.1", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "license": "ISC", + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "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" + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "license": "ISC" + }, "node_modules/yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", @@ -1481,6 +2544,15 @@ "engines": { "node": ">=6" } + }, + "node_modules/zod": { + "version": "3.23.8", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", + "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/package.json b/package.json index a786a23..34e4e1d 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,24 @@ "license": "ISC", "description": "", "devDependencies": { - "@types/express": "^5.0.0", + "@types/bcrypt": "^5.0.2", + "@types/express": "^4.17.21", + "@types/node": "^22.10.1", "nodemon": "^3.1.7", + "prisma": "^6.0.1", "ts-node": "^10.9.2", "typescript": "^5.7.2" }, "dependencies": { - "express": "^4.21.2" + "@prisma/client": "^6.0.1", + "@types/cors": "^2.8.17", + "@types/jsonwebtoken": "^9.0.7", + "bcrypt": "^5.1.1", + "cors": "^2.8.5", + "dotenv": "^16.4.7", + "express": "^4.21.2", + "jsonwebtoken": "^9.0.2", + "mongoose": "^8.8.4", + "zod": "^3.23.8" } } diff --git a/prisma/migrations/20241208170126_devsoc_backend_migrations/migration.sql b/prisma/migrations/20241208170126_devsoc_backend_migrations/migration.sql new file mode 100644 index 0000000..06917a8 --- /dev/null +++ b/prisma/migrations/20241208170126_devsoc_backend_migrations/migration.sql @@ -0,0 +1,17 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" SERIAL NOT NULL, + "name" TEXT NOT NULL, + "mobile" TEXT NOT NULL, + "email" TEXT NOT NULL, + "password" TEXT NOT NULL, + "institute" TEXT NOT NULL, + "yearOfStudy" INTEGER NOT NULL, + "interests" TEXT[], + "isAdmin" BOOLEAN NOT NULL, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/prisma/migrations/20241209205645_added_project_model/migration.sql b/prisma/migrations/20241209205645_added_project_model/migration.sql new file mode 100644 index 0000000..8957ff3 --- /dev/null +++ b/prisma/migrations/20241209205645_added_project_model/migration.sql @@ -0,0 +1,69 @@ +-- CreateTable +CREATE TABLE "Project" ( + "id" SERIAL NOT NULL, + "projectName" VARCHAR(50) NOT NULL, + "description" VARCHAR(700) NOT NULL, + "tags" TEXT[], + "capacity" INTEGER NOT NULL, + "thumbnail" TEXT NOT NULL, + "buttonClicks" INTEGER NOT NULL DEFAULT 1, + "createdAt" TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(6) NOT NULL, + "ownerId" INTEGER NOT NULL, + + CONSTRAINT "Project_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "_ProjectMembers" ( + "A" INTEGER NOT NULL, + "B" INTEGER NOT NULL, + + CONSTRAINT "_ProjectMembers_AB_pkey" PRIMARY KEY ("A","B") +); + +-- CreateTable +CREATE TABLE "_ProjectRequests" ( + "A" INTEGER NOT NULL, + "B" INTEGER NOT NULL, + + CONSTRAINT "_ProjectRequests_AB_pkey" PRIMARY KEY ("A","B") +); + +-- CreateTable +CREATE TABLE "_UserBookmarks" ( + "A" INTEGER NOT NULL, + "B" INTEGER NOT NULL, + + CONSTRAINT "_UserBookmarks_AB_pkey" PRIMARY KEY ("A","B") +); + +-- CreateIndex +CREATE INDEX "_ProjectMembers_B_index" ON "_ProjectMembers"("B"); + +-- CreateIndex +CREATE INDEX "_ProjectRequests_B_index" ON "_ProjectRequests"("B"); + +-- CreateIndex +CREATE INDEX "_UserBookmarks_B_index" ON "_UserBookmarks"("B"); + +-- AddForeignKey +ALTER TABLE "Project" ADD CONSTRAINT "Project_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_ProjectMembers" ADD CONSTRAINT "_ProjectMembers_A_fkey" FOREIGN KEY ("A") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_ProjectMembers" ADD CONSTRAINT "_ProjectMembers_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_ProjectRequests" ADD CONSTRAINT "_ProjectRequests_A_fkey" FOREIGN KEY ("A") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_ProjectRequests" ADD CONSTRAINT "_ProjectRequests_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_UserBookmarks" ADD CONSTRAINT "_UserBookmarks_A_fkey" FOREIGN KEY ("A") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_UserBookmarks" ADD CONSTRAINT "_UserBookmarks_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20241210003610_add_unique_constraint_to_slug/migration.sql b/prisma/migrations/20241210003610_add_unique_constraint_to_slug/migration.sql new file mode 100644 index 0000000..20300f4 --- /dev/null +++ b/prisma/migrations/20241210003610_add_unique_constraint_to_slug/migration.sql @@ -0,0 +1,11 @@ +/* + Warnings: + + - A unique constraint covering the columns `[slug]` on the table `Project` will be added. If there are existing duplicate values, this will fail. + +*/ +-- AlterTable +ALTER TABLE "Project" ADD COLUMN "slug" TEXT NOT NULL DEFAULT ''; + +-- CreateIndex +CREATE UNIQUE INDEX "Project_slug_key" ON "Project"("slug"); diff --git a/prisma/migrations/20241211020055_added_username/migration.sql b/prisma/migrations/20241211020055_added_username/migration.sql new file mode 100644 index 0000000..f58b1e5 --- /dev/null +++ b/prisma/migrations/20241211020055_added_username/migration.sql @@ -0,0 +1,12 @@ +/* + Warnings: + + - A unique constraint covering the columns `[username]` on the table `User` will be added. If there are existing duplicate values, this will fail. + - Added the required column `username` to the `User` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "User" ADD COLUMN "username" TEXT NOT NULL DEFAULT 'default_username'; + +-- CreateIndex +CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); diff --git a/prisma/migrations/20241211020517_added_username_unique/migration.sql b/prisma/migrations/20241211020517_added_username_unique/migration.sql new file mode 100644 index 0000000..8837bbb --- /dev/null +++ b/prisma/migrations/20241211020517_added_username_unique/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "User" ALTER COLUMN "username" DROP DEFAULT; diff --git a/prisma/migrations/20241211151613_add_blog_model/migration.sql b/prisma/migrations/20241211151613_add_blog_model/migration.sql new file mode 100644 index 0000000..335b247 --- /dev/null +++ b/prisma/migrations/20241211151613_add_blog_model/migration.sql @@ -0,0 +1,17 @@ +-- CreateTable +CREATE TABLE "Blog" ( + "id" SERIAL NOT NULL, + "blogName" TEXT NOT NULL, + "slug" TEXT NOT NULL, + "content" TEXT NOT NULL, + "tagline" TEXT NOT NULL, + "thumbnail" TEXT NOT NULL, + "author" TEXT NOT NULL, + "upvotes" INTEGER NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Blog_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Blog_slug_key" ON "Blog"("slug"); diff --git a/prisma/migrations/20241211175455_added_blog_relations/migration.sql b/prisma/migrations/20241211175455_added_blog_relations/migration.sql new file mode 100644 index 0000000..c48b653 --- /dev/null +++ b/prisma/migrations/20241211175455_added_blog_relations/migration.sql @@ -0,0 +1,11 @@ +/* + Warnings: + + - Added the required column `ownerId` to the `Blog` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "Blog" ADD COLUMN "ownerId" INTEGER NOT NULL; + +-- AddForeignKey +ALTER TABLE "Blog" ADD CONSTRAINT "Blog_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20241217200141_changed_some_default_values/migration.sql b/prisma/migrations/20241217200141_changed_some_default_values/migration.sql new file mode 100644 index 0000000..42654a4 --- /dev/null +++ b/prisma/migrations/20241217200141_changed_some_default_values/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "Project" ALTER COLUMN "slug" DROP DEFAULT; + +-- AlterTable +ALTER TABLE "User" ALTER COLUMN "isAdmin" SET DEFAULT false; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..fbffa92 --- /dev/null +++ b/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (i.e. Git) +provider = "postgresql" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma new file mode 100644 index 0000000..78897b7 --- /dev/null +++ b/prisma/schema.prisma @@ -0,0 +1,68 @@ + +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +model User { + id Int @id @default(autoincrement()) + username String @unique + name String + mobile String + email String @unique + password String + institute String + yearOfStudy Int + interests String[] + isAdmin Boolean @default(false) + + // Relations + bookmarks Project[] @relation("UserBookmarks") // Projects bookmarked by the user + projects Project[] @relation("UserProjects") // Projects owned by the user + memberOf Project[] @relation("ProjectMembers") // Projects where the user is a member + requests Project[] @relation("ProjectRequests") // Projects where the user has requested to join + blogs Blog[] @relation("UserBlogs") //Blogs owned by the user +} + +model Project { + id Int @id @default(autoincrement()) + slug String @unique + projectName String @db.VarChar(50) + description String @db.VarChar(700) + tags String[] + capacity Int + thumbnail String + buttonClicks Int @default(1) + + // Timestamps + createdAt DateTime @default(now()) @db.Timestamp(6) + updatedAt DateTime @updatedAt @db.Timestamp(6) + + // Relations + owner User @relation("UserProjects", fields: [ownerId], references: [id]) // Owner of the project + ownerId Int + members User[] @relation("ProjectMembers") // Users who are members + requests User[] @relation("ProjectRequests") // Users who have requested to join + bookmarkedBy User[] @relation("UserBookmarks") // Users who have bookmarked the project +} + +model Blog { + id Int @id @default(autoincrement()) + blogName String + slug String @unique + content String + tagline String + thumbnail String + author String + upvotes Int @default(0) + createdAt DateTime @default(now()) + + //Relations + + owner User @relation("UserBlogs", fields: [ownerId], references: [id]) // Owner of the blog + ownerId Int +} diff --git a/src/Routers/blogRoute.ts b/src/Routers/blogRoute.ts new file mode 100644 index 0000000..da46cf1 --- /dev/null +++ b/src/Routers/blogRoute.ts @@ -0,0 +1,14 @@ +import { Router } from "express"; +import { authMiddleware } from "../middlewares/auth"; +import { createBlog, deleteBlog, getAllBlogs, getBlogByslug, getUserBlogs, updateBlog } from "../controllers/blogs"; +const blogRouter:Router = Router(); + +blogRouter.post('/create',authMiddleware,createBlog); +blogRouter.put('/:slug',authMiddleware,updateBlog); +blogRouter.delete('/:slug',authMiddleware,deleteBlog); +blogRouter.get('/',getAllBlogs); +blogRouter.get('/:slug',getBlogByslug); +blogRouter.get('/blogs/:username',getUserBlogs) + + +export default blogRouter; \ No newline at end of file diff --git a/src/Routers/index.ts b/src/Routers/index.ts new file mode 100644 index 0000000..626d461 --- /dev/null +++ b/src/Routers/index.ts @@ -0,0 +1,14 @@ +import { Router } from "express"; +import userRouter from "./userRoute"; +import projectRouter from "./projectRoute"; +import blogRouter from "./blogRoute"; +import { signin, signup } from "../controllers/user"; +const mainRouter:Router = Router(); + +mainRouter.use("/user",userRouter); +mainRouter.use("/projects",projectRouter); +mainRouter.use('/blogs',blogRouter); +mainRouter.use('/signup',signup); +mainRouter.use('/signin',signin); + +export default mainRouter; \ No newline at end of file diff --git a/src/Routers/projectRoute.ts b/src/Routers/projectRoute.ts new file mode 100644 index 0000000..ebd37b5 --- /dev/null +++ b/src/Routers/projectRoute.ts @@ -0,0 +1,14 @@ +import { Router } from "express"; +import { createProject, deleteProject, getAllProjects, getProjectBySlug, getUserProjects, updateProject } from "../controllers/projects"; +import { authMiddleware } from "../middlewares/auth"; + +const projectRouter:Router = Router(); +projectRouter.post('/create', authMiddleware, createProject); +projectRouter.put('/:slug',authMiddleware,updateProject); +projectRouter.delete('/:slug',authMiddleware,deleteProject); +projectRouter.get('/',getAllProjects); +projectRouter.get('/:slug',getProjectBySlug); +projectRouter.get('/projects/:username',getUserProjects) + + +export default projectRouter; \ No newline at end of file diff --git a/src/Routers/userRoute.ts b/src/Routers/userRoute.ts new file mode 100644 index 0000000..12a0e44 --- /dev/null +++ b/src/Routers/userRoute.ts @@ -0,0 +1,15 @@ +import { Router } from "express"; +import { addBookmark, fetchUserDetails, removeBookmark, sendRequest, userUpdate } from "../controllers/user"; +import { authMiddleware } from "../middlewares/auth"; + + +const userRouter = Router(); + +userRouter.get('/',authMiddleware, fetchUserDetails); +userRouter.put('/',authMiddleware,userUpdate); +userRouter.post('/bookmark',authMiddleware,addBookmark); +userRouter.delete('/bookmark',authMiddleware,removeBookmark); +userRouter.post('/send-request',authMiddleware,sendRequest); + +export default userRouter; + diff --git a/src/Validation/ZodValidation.ts b/src/Validation/ZodValidation.ts new file mode 100644 index 0000000..02046cf --- /dev/null +++ b/src/Validation/ZodValidation.ts @@ -0,0 +1,124 @@ +import zod from "zod"; + +const signupBody = zod.object({ + name: zod + .string() + .min(1, "Name is required") + .max(50, "Name must be 50 characters or fewer"), + username: zod + .string() + .min(3, "Username must be at least 3 characters long") + .max(30, "Username must be 30 characters or fewer"), + mobile: zod + .string() + .regex(/^\d{10}$/, "Mobile must be a 10-digit number"), // Assuming mobile number is 10 digits + email: zod + .string() + .email("Invalid email address") + .max(100, "Email must be 100 characters or fewer"), + password: zod + .string() + .min(6, "Password must be at least 6 characters long") + .max(50, "Password must be 50 characters or fewer"), + institute: zod.enum(["IIT Kharagpur"], { + errorMap: () => ({ message: "Institute must be IIT Kharagpur" }), + }), + yearOfStudy: zod + .number() + .min(1, "Year of study must be at least 1") + .max(10, "Year of study must be 10 or fewer"), // Assuming a cap of 10 years + interests: zod + .array(zod.string().min(1, "Interest cannot be empty")) + .max(20, "You can have a maximum of 20 interests"), + isAdmin: zod.boolean(), +}); + +const signinBody = zod.object({ + email: zod + .string() + .email("Invalid email address") + .max(100, "Email must be 100 characters or fewer"), + password: zod + .string() + .min(6, "Password must be at least 6 characters long") + .max(50, "Password must be 50 characters or fewer"), +}); + +const updateUserBody = zod.object({ + mobile: zod + .string() + .regex(/^\d{10}$/, "Mobile must be a 10-digit number") + .optional(), + password: zod + .string() + .min(6, "Password must be at least 6 characters long") + .max(50, "Password must be 50 characters or fewer") + .optional(), + interests: zod + .array(zod.string().min(1, "Interest cannot be empty")) + .max(20, "You can have a maximum of 20 interests") + .optional(), +}); + +const projectBaseSchema = zod.object({ + projectName: zod + .string() + .min(1, "Project name is required") + .max(50, "Project name must be 50 characters or fewer"), + slug: zod + .string(), + description: zod + .string() + .min(1, "Description is required") + .max(700, "Description must be 700 characters or fewer"), + tags: zod + .array(zod.string()) + .optional(), + capacity: zod + .number() + .int("Capacity must be an integer") + .positive("Capacity must be greater than 0"), + thumbnail: zod + .string() + .url("Thumbnail must be a valid URL"), +}); + +const createProjectSchema = projectBaseSchema; +const updateProjectSchema = projectBaseSchema; + +const blogBaseSchema = zod.object({ + blogName: zod + .string() + .min(1, "Blog name is required") + .max(50, "Blog name must be 50 characters or fewer"), + slug: zod + .string(), + content: zod + .string() + .min(1, "Content is required") + .max(5000, "Content must be 5000 characters or fewer"), // Optional limit for long content + tagline: zod + .string() + .min(1, "Tagline is required") + .max(150, "Tagline must be 150 characters or fewer"), + author: zod + .string() + .min(1, "Author name is required") + .max(50, "Author name must be 50 characters or fewer"), + thumbnail: zod + .string() + .url("Thumbnail must be a valid URL"), +}); + +const createBlogSchema = blogBaseSchema; +const updateBlogSchema = blogBaseSchema; + +export { + signupBody, + signinBody, + updateUserBody, + createProjectSchema, + updateProjectSchema, + createBlogSchema, + updateBlogSchema, +}; diff --git a/src/controllers/blogs.ts b/src/controllers/blogs.ts new file mode 100644 index 0000000..22669ee --- /dev/null +++ b/src/controllers/blogs.ts @@ -0,0 +1,222 @@ +import { Request, Response } from "express"; +import { PrismaClient } from "@prisma/client"; +import { createBlogSchema, updateBlogSchema } from "../Validation/ZodValidation"; + +//use console.log(parseResult.error) in return json to find errors in input validation + +const client = new PrismaClient(); + +const createBlog = async (req:Request,res:Response) => { + const userId = req.user.id; + const body = req.body; + try{ + const parseResult = createBlogSchema.safeParse(body); + if(!parseResult.success){ + return res.status(400).json({ + success:false, + message:"Validation Failed", + errors:parseResult.error.issues + }) + } + const { blogName,content,tagline,author,thumbnail,slug } = parseResult.data; + const existingBlog = await client.blog.findFirst({ + where: { + slug : slug + } + }) + if(existingBlog){ + return res.json({ + success:false, + message : "A blog with this name already exists" + }) + } + const blog = await client.blog.create({ + data:{ + blogName, + content, + tagline, + author, + thumbnail, + slug, + ownerId:userId + } + }) + res.status(201).json({ + success : true, + data: blog, + message:"Blog created successfully" + }) + }catch(error){ + console.error("Cannot Create Blog",error) + res.status(500).json({ + message: "Internal Server Error" + }) + + } +} + +const updateBlog = async(req:Request,res:Response) => { + try{ + const userId = req.user.id; + const slug=req.params.slug; + const parseResult = updateBlogSchema.safeParse(req.body); + if(!parseResult.success){ + return res.status(400).json({ + success : false, + message : "Error while validating inputs", + errors:parseResult.error.issues + }) + } + const blog = await client.blog.findUnique({ + where:{ + slug:slug + } + }) + if(!blog){ + return res.status(404).json({ + success:false, + message : "Blog not found" + }) + } + if(blog.ownerId!=userId){ + return res.status(403).json({ + success : false, + message : "You are not authorized to edit this blog" + }) + } + let updatedData=parseResult.data; + const updatedBlog = await client.blog.update({ + where : {slug : slug}, + data : updatedData + }) + res.status(200).json({ + success : true, + message : "Blog updated successfully", + data: updatedBlog, + }) + }catch(error){ + console.error("Error while updating Blog",error) + res.status(500).json({ + message : "Internal Server Error" + }) + } +} + +const deleteBlog = async (req:Request,res:Response) => { + try{ + const userId = req.user.id; + const slug = req.params.slug; + const blog = await client.blog.findUnique({ + where : { + slug:slug + } + }) + if(!blog){ + return res.status(404).json({ + success : false, + message : "Blog not Found" + }) + } + if(blog.ownerId!=userId){ + return res.status(403).json({ + success : false, + message : "You are not authorized to delete this blog" + }); + } + await client.blog.delete({ + where : { + slug:slug + } + }); + return res.status(200).json({ + success : true, + message : "Blog Deleted Succesfully" + }) + + }catch(error){ + console.error("Unable to delete Blog",error) + return res.status(500).json({ + success : false, + message : "Intenal server error" + }) + } +} + +const getAllBlogs = async ( req:Request,res:Response) => { + try{ + const allBlogs = await client.blog.findMany(); + res.status(200).json({ + success : true, + data : allBlogs + }) + }catch(error){ + console.error("Error fetching all blogs",error); + res.status(500).json({ + success : false, + message : "Internal Server Error" + }) + } +} + +const getBlogByslug = async (req:Request,res:Response)=>{ + try{ + const slug=req.params.slug; + const blog = await client.blog.findUnique({ + where : { + slug:slug + } + }) + if(!blog){ + return res.status(403).json({ + success:false, + message:"Blog not found" + }) + } + res.status(200).json({ + success:true, + data:blog + }) + }catch (err) { + console.error("Error fetching Blog by slug:", err); + res.status(500).json({ + success: false, + message: "Internal server error", + }); + } +} + +const getUserBlogs = async (req:Request,res:Response)=>{ + try{ + const username = req.params.username; + const user = await client.user.findUnique({ + where :{ + username + } + }) + if(!user){ + return res.status(403).json({ + success:false, + message:"Username Not found" + }) + } + const userId = user.id; + const blogs = await client.blog.findMany({ + where:{ + ownerId:userId + } + }); + return res.status(200).json({ + success:true, + message:"Blogs fetched succesfully", + data : blogs, + }); + }catch(error){ + console.error("Error fetching user projects:", error); + return res.status(500).json({ + success: false, + message: "Internal Server Error", + }); + } +} + +export {createBlog,updateBlog,deleteBlog,getAllBlogs,getBlogByslug,getUserBlogs} \ No newline at end of file diff --git a/src/controllers/projects.ts b/src/controllers/projects.ts new file mode 100644 index 0000000..4552618 --- /dev/null +++ b/src/controllers/projects.ts @@ -0,0 +1,214 @@ +import { Request, Response } from "express"; +import { PrismaClient } from "@prisma/client"; +import { createProjectSchema, updateProjectSchema } from "../Validation/ZodValidation"; // Assuming validation file + +const client = new PrismaClient(); + +const createProject = async (req: Request, res: Response) => { + const userId = req.user.id; + try { + const parseResult = createProjectSchema.safeParse(req.body); + if (!parseResult.success) { + return res.status(400).json({ + success: false, + message: "Validation failed", + errors:parseResult.error.issues + }); + } + const { projectName, description, tags, capacity, thumbnail,slug } = parseResult.data; + const existingProject = await client.project.findFirst({ + where: { + slug: slug, + }, + }); + if (existingProject) { + return res.status(400).json({ + success: false, + message: "A project with this name already exists for the user", + }); + } + const project = await client.project.create({ + data: { + projectName, + description, + tags, + capacity, + thumbnail, + ownerId: userId, + slug, + }, + }); + res.status(201).json({ + success: true, + data: project, + }); + } catch (err) { + console.error("Error while creating project:", err); + res.status(500).json({ + success: false, + message: "Internal Server Error", + }); + } +}; + +const updateProject = async (req: Request, res: Response) => { + const userId = req.user.id; + const slug = req.params.slug + try { + const body = req.body; + const parseResult = updateProjectSchema.safeParse(body); + if (!parseResult.success) { + return res.status(400).json({ + success: false, + message: "Error while validating inputs", + errors:parseResult.error.issues + }); + } + const project = await client.project.findUnique({ + where: { slug:slug }, + }); + if (!project) { + return res.status(404).json({ + success: false, + message: "Project not found", + }); + } + if (project.ownerId !== userId) { + return res.status(403).json({ + success: false, + message: "You are not authorized to update this project", + }); + } + let updatedData = parseResult.data; + const updatedProject = await client.project.update({ + where: { slug:slug }, + data: updatedData, + }); + res.status(200).json({ + success: true, + message: "Project updated successfully", + data: updatedProject, + }); + } catch (error) { + console.error("Error while updating project details:", error); + res.status(500).json({ + success: false, + message: "Internal server error", + }); + } +} + +const deleteProject = async (req: Request, res: Response) => { + const userId = req.user.id; + const slug = req.params.slug; + try { + const project = await client.project.findUnique({ + where: { slug: slug }, + }); + if (!project) { + return res.status(404).json({ + success: false, + message: "Project not found", + }); + } + if (project.ownerId !== userId) { + return res.status(403).json({ + success: false, + message: "You are not authorized to delete this project", + }); + } + await client.project.delete({ + where: { slug: slug }, + }); + return res.status(200).json({ + success: true, + message: "Project deleted successfully", + }); + } catch (error) { + console.error("Error while deleting the Project", error); + return res.status(500).json({ + success: false, + message: "Internal Server Error", + }); + } +}; + + +const getAllProjects = async (req: Request, res: Response) => { + try { + const allProjects = await client.project.findMany(); + res.status(200).json({ + success: true, + data: allProjects, + }); + } catch (error) { + console.error("Error fetching all projects:", error); + res.status(500).json({ + success: false, + message: "Internal Server Error", + }); + } +}; + + +const getProjectBySlug = async (req:Request, res:Response) => { + try { + const slug = req.params.slug; + const project = await client.project.findUnique({ + where: { slug: slug }, + }); + if (!project) { + return res.status(404).json({ + success: false, + message: "Project not found", + }); + } + res.status(200).json({ + success: true, + data: project, + }); + } catch (err) { + console.error("Error fetching project by slug:", err); + res.status(500).json({ + success: false, + message: "Internal server error", + }); + } +}; + +const getUserProjects = async (req: Request, res: Response) => { + try { + const username = req.params.username; + const user = await client.user.findUnique({ + where: { + username: username, + }, + }); + if (!user) { + return res.status(404).json({ + success: false, + message: "Username not found", + }); + } + const userId = user.id; + const projects = await client.project.findMany({ + where: { + ownerId: userId, + }, + }); + return res.status(200).json({ + success: true, + message: "Projects fetched successfully", + data: projects, + }); + } catch (error) { + console.error("Error fetching user projects:", error); + return res.status(500).json({ + success: false, + message: "Internal Server Error", + }); + } +}; + + +export {createProject,updateProject,deleteProject,getAllProjects,getProjectBySlug,getUserProjects} diff --git a/src/controllers/user.ts b/src/controllers/user.ts new file mode 100644 index 0000000..d654687 --- /dev/null +++ b/src/controllers/user.ts @@ -0,0 +1,230 @@ +import { Request, Response } from "express"; +import { PrismaClient } from '@prisma/client' +import bcrypt from "bcrypt"; +import { signupBody,signinBody, updateUserBody } from "../Validation/ZodValidation"; +import jwt from "jsonwebtoken"; +import dotenv from "dotenv"; +dotenv.config(); + +const client = new PrismaClient(); + +const JWT_SECRET = process.env.JWT_SECRET || "defaultsecretkey"; +const signup = async (req: Request, res: Response) => { + try { + const body = req.body; + const parseResult = signupBody.safeParse(body); + if (!parseResult.success) { + return res.status(400).json({ message: "Invalid Inputs", success:false}); + } + const { name, username, mobile, email, password, institute, yearOfStudy, interests, isAdmin } = parseResult.data; + if (!email.endsWith("@iitkgp.ac.in")) { + return res.status(400).json({ + message: "Please enter Institute Email Address", + success: false, + }); + } + const existingUser = await client.user.findUnique({ + where: { email }, + }); + if (existingUser) { + return res.status(409).json({ message: "Email already registered" ,success:false}); + } + const saltRounds = 10; + const hashedPassword = await bcrypt.hash(password, saltRounds); + const newUser = await client.user.create({ + data: { + name, + username, + mobile, + email, + password: hashedPassword, + institute, + yearOfStudy, + interests, + isAdmin, + }, + }); + const token = jwt.sign({ id: newUser.id }, JWT_SECRET, { expiresIn: "1h" }); + return res.status(201).json({ + message: "User registered successfully", + user: { id: newUser.id, email: newUser.email }, + token, + success:true + }); + } catch (error) { + console.error("Error in signup:", error); + return res.status(500).json({ message: "Internal Server Error",success:false }); + } +}; + + const signin = async (req: Request, res: Response) => { + try { + const body = req.body; + const parseResult = signinBody.safeParse(body); + if (!parseResult.success) { + return res.status(400).json({ + message: "Invalid Inputs", + success:false + }); + } + const { email, password } = parseResult.data; + if (!email.endsWith("@iitkgp.ac.in")) { + return res.status(400).json({ + message: "Email must end with @iitkgp.ac.in", + success: false, + }); + } + const user = await client.user.findUnique({ + where: { email } + }); + + if (!user) { + return res.status(401).json({ message: "Invalid credentials",success:false}); + } + const isPasswordValid = await bcrypt.compare(password, user.password); + if (!isPasswordValid) { + return res.status(401).json({ message: "Invalid credentials",success:false }); + } + const token = jwt.sign({ id: user.id }, JWT_SECRET, { expiresIn: "1h" }); + return res.status(200).json({ + message: "Signin successful", + user: { id: user.id, email: user.email }, + token, + success:true + }); + } catch (error) { + console.error("Error during signin:", error); + return res.status(500).json({ message: "Internal Server Error" ,success:false}); + } +}; + +const fetchUserDetails = async (req: Request, res: Response) => { + const user = req.user; + if (!user) { + return res.status(400).json({ message: "User data is not available", success: false }); + } + try { + return res.status(200).json({ + user , + success : true + }); + } catch (error) { + console.error("Error during fetching user details", error); + return res.status(500).json({ message: "Internal Server Error", success: false }); + } +}; + + +const userUpdate = async (req: Request, res: Response) => { + const userId=req.user.id; + try { + const body = req.body; + const parseResult = updateUserBody.safeParse(body); + if (!parseResult.success) { + return res.status(400).json({ + message: "Invalid inputs", + success:false + }); + } + if (parseResult.data.password) { + // Hash the password using bcrypt + const saltRounds = 10; + parseResult.data.password = await bcrypt.hash(parseResult.data.password, saltRounds); + } + const updatedUser = await client.user.update({ + where: { id: userId }, + data: parseResult.data, + }); + return res.status(200).json({ + message: "User details updated successfully", + user: updatedUser, + success : true + }); + } catch (error) { + console.error("Error during updating the user details:", error); + return res.status(500).json({ message: "Internal Server Error",success:false }); + } +}; + +const addBookmark = async (req: Request, res: Response) => { + const userId = req.user.id; // Assuming the user ID is set in the request by a middleware + const projectId = req.body.projectId; + if (!projectId) { + return res.status(400).json({ success: false, message: "Project ID is required" }); + } + try { + const updatedUser = await client.user.update({ + where: { id: userId }, + data: { + bookmarks: { + connect: { id: projectId }, // Connect the project to the user's bookmarks + }, + }, + include: { bookmarks: true }, // Include the updated bookmarks in the response + }); + + return res.status(200).json({ success: true, data: updatedUser }); + } catch (error) { + console.error("Error adding bookmark:", error); + return res.status(500).json({ success: false, message: "Internal Server Error" }); + } +}; + +const removeBookmark = async (req: Request, res: Response) => { + const userId = req.user.id; // Assuming the user ID is set in the request by a middleware + const projectId = req.body.projectId; + if (!projectId) { + return res.status(400).json({ success: false, message: "Project ID is required" }); + } + try { + const updatedUser = await client.user.update({ + where: { id: userId }, + data: { + bookmarks: { + disconnect: { id: projectId }, // Connect the project to the user's bookmarks + }, + }, + include: { bookmarks: true }, // Include the updated bookmarks in the response + }); + + return res.status(200).json({ success: true, data: updatedUser }); + } catch (error) { + console.error("Error adding bookmark:", error); + return res.status(500).json({ success: false, message: "Internal Server Error" }); + } +}; + +const sendRequest = async(req:Request,res:Response)=>{ + try{ + const userId= req.user.id; + const projectId = req.body.projectId; + if(!projectId){ + return res.status(400).json({ + success : false, + message:"Project not found" + }) + } + const projectRequested = await client.user.update({ + where : {id:userId}, + data: { + requests: { + connect : {id : projectId}, + } + }, + include : {requests:true} + }); + return res.status(200).json({ + success : true, + data:projectRequested + }) + }catch(error){ + console.error("Error sending request:", error); + return res.status(500).json({ success: false, message: "Internal Server Error" }); + } +} + + + +export {signup,signin,fetchUserDetails,userUpdate,addBookmark,removeBookmark,sendRequest}; + + diff --git a/src/middlewares/auth.ts b/src/middlewares/auth.ts new file mode 100644 index 0000000..3117432 --- /dev/null +++ b/src/middlewares/auth.ts @@ -0,0 +1,53 @@ +import jwt from "jsonwebtoken"; +import { Request, Response, NextFunction } from "express"; +import dotenv from "dotenv"; +import { PrismaClient } from "@prisma/client"; +dotenv.config(); + +const JWT_SECRET = process.env.JWT_SECRET || "yoursecretkey"; + +declare global { + namespace Express { + interface Request { + user?: any; + } + } +} + +const client = new PrismaClient(); +async function authMiddleware(req: Request, res: Response, next: NextFunction) { + try { + const authHeader = req.header("Authorization"); + if (!authHeader || !authHeader.startsWith("Bearer ")) { + return res.status(403).json({ message: "No token provided or incorrect format", success: false }); + } + const token = authHeader.split(" ")[1]; + if (!token) { + return res.status(403).json({ message: "Token missing" , success: false}); + } + const decoded = jwt.verify(token, JWT_SECRET) as jwt.JwtPayload; + if (!decoded || !decoded.id) { + return res.status(403).json({ message: "Invalid token" , success: false}); + } + const id = decoded.id; + try { + const userDetails = await client.user.findUnique({ + where: { id }, + }); + if (userDetails) { + req.user = userDetails; + next(); + } else { + return res.status(404).json({ message: "User not found", success: false }); + } + } catch (error) { + console.error("Error during fetching user details", error); + return res.status(500).json({ message: "Internal Server Error" ,success: false}); + } + } catch (err) { + console.error("Error during token verification:", err); + return res.status(403).json({ message: "Invalid token or token verification failed",success: false }); + } +} + +export { authMiddleware }; diff --git a/src/server.ts b/src/server.ts index b0b5ee3..d7fd85c 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,12 +1,18 @@ import express from 'express'; +import cors from "cors"; +import dotenv from "dotenv"; +import mainRouter from './Routers'; +dotenv.config(); const app = express(); -const port = process.env.PORT || 8000; -app.get('/', (req, res) => { - res.send('Hello World!'); -}); +app.use(cors()); +app.use(express.json()); -app.listen(port, () => { - console.log(`Server is running on port ${port}`); -}); +// Routes +app.use("/api/v1",mainRouter); + +const PORT = process.env.PORT || 3001; +app.listen(PORT, () => { + console.log(`Server running on port ${PORT}`); +}); \ No newline at end of file