diff --git a/app/action/sendContactEmail.js b/app/action/sendContactEmail.js index 27d2d57..719e867 100644 --- a/app/action/sendContactEmail.js +++ b/app/action/sendContactEmail.js @@ -10,7 +10,7 @@ export async function sendContactEmail(username, fromEmail, message, subject) { subject: subject, html: ContactEmailTemplate({ username, message, fromEmail }), }); - console.log(res); + if (!res.data) throw new Error(res.error.name); return { diff --git a/app/api/teams/create-team/route.jsx b/app/api/teams/create-team/route.jsx index 60547f3..d518950 100644 --- a/app/api/teams/create-team/route.jsx +++ b/app/api/teams/create-team/route.jsx @@ -1,7 +1,7 @@ import dbConnect from "../../../../lib/dbConnect"; import { teamSchema } from "../../../../model/Schema/teamSchema"; import { TeamModel } from "../../../../model/Team"; -import { UserModel } from "../../../../model/User"; +import UserModel from "../../../../model/User"; export async function POST(request) { await dbConnect(); diff --git a/app/api/teams/send-request/route.js b/app/api/teams/send-request/route.js index 08c3b76..8997e64 100644 --- a/app/api/teams/send-request/route.js +++ b/app/api/teams/send-request/route.js @@ -1,6 +1,6 @@ import dbConnect from "../../../../lib/dbConnect"; import { TeamModel } from "../../../../model/Team"; -import { UserModel } from "../../../../model/User"; +import UserModel from "../../../../model/User"; export async function POST(req) { await dbConnect(); diff --git a/model/User.js b/model/User.ts similarity index 56% rename from model/User.js rename to model/User.ts index 05389dc..3641556 100644 --- a/model/User.js +++ b/model/User.ts @@ -1,7 +1,30 @@ -import mongoose, { models, model } from "mongoose"; -const { Schema } = mongoose; +import mongoose, { Document, Model, Schema } from "mongoose"; -const userSchema = new Schema({ +interface IUser extends Document { + username: string; + name?: string; + email: string; + bio?: string; + discordId?: string; + googleId?: string; + twoFactorActivated: boolean; + createdAt: Date; + verifyCode: string; + verifyCodeExpiry: Date; + password: string; + eventsRegistered: Array; +} + +interface IUserMethods { + updatePassword(newPassword: string): Promise; +} + +interface IUserModel extends Model { + findByEmail(email: string): Promise; +} + +// Created the User Schema +const userSchema = new Schema({ _id: { type: Schema.Types.ObjectId, required: true, @@ -62,6 +85,8 @@ const userSchema = new Schema({ ], }); -const UserModel = models.UserModel || model("UserModel", userSchema); - +// Created the User Model +const UserModel = + mongoose.models.UserModel || + mongoose.model("UserModel", userSchema); export default UserModel; diff --git a/package-lock.json b/package-lock.json index 7ac6633..2c6af61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,6 +63,7 @@ "@eslint/js": "^9.17.0", "@tailwindcss/typography": "0.5.13", "@types/bcryptjs": "^2.4.6", + "@types/mongoose": "^5.11.97", "@types/node": "20.11.24", "@types/react": "18.2.61", "@types/react-dom": "18.2.19", @@ -2566,7 +2567,6 @@ "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", "dev": true, - "license": "MIT", "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } @@ -2624,7 +2624,6 @@ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.2.0.tgz", "integrity": "sha512-grOjVNN8P3hjJn/eIETF1wwd12DdnwFDoyceUJLYYdkpbwq3nLi+4fqrTAONx7XDALqlL220wC/RHSC/QTI/0w==", "dev": true, - "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", @@ -2658,7 +2657,6 @@ "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "dev": true, - "license": "MIT", "engines": { "node": ">=18" }, @@ -2683,7 +2681,6 @@ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.17.0.tgz", "integrity": "sha512-Sxc4hqcs1kTu0iID3kcZDW3JHq2a77HO9P8CP6YEA/FpH3Ll8UXE2r/86Rz9YJLKme39S9vU5OWNjC6Xl0Cr3w==", "dev": true, - "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } @@ -4077,13 +4074,13 @@ } }, "node_modules/@portabletext/editor": { - "version": "1.16.3", - "resolved": "https://registry.npmjs.org/@portabletext/editor/-/editor-1.16.3.tgz", - "integrity": "sha512-xMxyVTBCgajrIW9JNLxflq0g/vtMdTzyD1K7w1gVmt0KGPYssBdOkERGrxw1SED66kMB2FgRAgJpVOSFdevNHA==", + "version": "1.18.5", + "resolved": "https://registry.npmjs.org/@portabletext/editor/-/editor-1.18.5.tgz", + "integrity": "sha512-ubHLFz6Z+7gG5Ptk8CqaVMF0xxTusOMp4fAHxh2R//olLX9gKfcUBv6VzlQhnxIYRGVeHB+FmOXUkI9z5cGmDg==", "license": "MIT", "peer": true, "dependencies": { - "@portabletext/patches": "1.1.0", + "@portabletext/patches": "1.1.1", "@xstate/react": "^5.0.0", "debug": "^4.3.4", "get-random-values-esm": "^1.0.2", @@ -4100,14 +4097,24 @@ "node": ">=18" }, "peerDependencies": { - "@sanity/block-tools": "^3.67.1", - "@sanity/schema": "^3.67.1", - "@sanity/types": "^3.67.1", + "@sanity/block-tools": "^3.68.3", + "@sanity/schema": "^3.68.3", + "@sanity/types": "^3.68.3", "react": "^16.9 || ^17 || ^18 || ^19", "rxjs": "^7.8.1", "styled-components": "^6.1.13" } }, + "node_modules/@portabletext/editor/node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/@portabletext/editor/node_modules/slate-react": { "version": "0.112.0", "resolved": "https://registry.npmjs.org/slate-react/-/slate-react-0.112.0.tgz", @@ -4130,21 +4137,14 @@ "slate-dom": ">=0.110.2" } }, - "node_modules/@portabletext/editor/node_modules/tiny-invariant": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.1.tgz", - "integrity": "sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==", - "license": "MIT", - "peer": true - }, "node_modules/@portabletext/patches": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@portabletext/patches/-/patches-1.1.0.tgz", - "integrity": "sha512-2qn4WaRc23m5qRwclT3sAyuHwTyjxCb4Lg0BQyhp7CABd83HtnPPYoP6hycREs6HRdWA48H3sU5gqUVPoxJxdg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@portabletext/patches/-/patches-1.1.1.tgz", + "integrity": "sha512-FXeVdLvSJ3JmZzS0dbxEFJZXplFo7K27/Twv0/dX/l86tfhhUkDSqaTlWcigxuibvohjdEYp2mB8Ucgao/JzIQ==", "license": "MIT", "peer": true, "dependencies": { - "@sanity/diff-match-patch": "^3.1.1", + "@sanity/diff-match-patch": "^3.1.2", "lodash": "^4.17.21" } }, @@ -8645,6 +8645,16 @@ "license": "MIT", "peer": true }, + "node_modules/@types/mongoose": { + "version": "5.11.97", + "resolved": "https://registry.npmjs.org/@types/mongoose/-/mongoose-5.11.97.tgz", + "integrity": "sha512-cqwOVYT3qXyLiGw7ueU2kX9noE8DPGRY6z8eUxudhXY8NZ7DMKYAxyZkLSevGfhCX3dO/AoX5/SO9lAzfjon0Q==", + "deprecated": "Mongoose publishes its own types, so you do not need to install this package.", + "dev": true, + "dependencies": { + "mongoose": "*" + } + }, "node_modules/@types/node": { "version": "20.11.24", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.24.tgz", @@ -8898,6 +8908,7 @@ "version": "8.18.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.18.1.tgz", "integrity": "sha512-7uoAUsCj66qdNQNpH2G8MyTFlgerum8ubf21s3TSM3XmKXuIn+H2Sifh/ES2nPOPiYSRJWAk0fDkW0APBWcpfw==", + "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, @@ -8960,7 +8971,6 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.1.tgz", "integrity": "sha512-Vj0WLm5/ZsD013YeUKn+K0y8p1M0jPpxOkKdbD1wB0ns53a5piVY02zjf072TblEweAbcYiFiPoSMF3kp+VhhQ==", "dev": true, - "license": "MIT", "dependencies": { "@typescript-eslint/types": "8.18.1", "eslint-visitor-keys": "^4.2.0" @@ -10226,8 +10236,7 @@ "node_modules/classnames": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz", - "integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==", - "license": "MIT" + "integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==" }, "node_modules/cli-cursor": { "version": "3.1.0", @@ -10236,28 +10245,10 @@ "license": "MIT", "peer": true, "dependencies": { - "@typescript-eslint/types": "8.18.1", - "eslint-visitor-keys": "^4.2.0" + "restore-cursor": "^3.1.0" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/cli-cursor/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", - "license": "Apache-2.0", - "peer": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" + "node": ">=8" } }, "node_modules/cli-spinners": { @@ -10381,19 +10372,6 @@ "node": ">=6" } }, - "node_modules/clone-deep/node_modules/is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "license": "MIT", - "peer": true, - "dependencies": { - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/clsx": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", @@ -11931,7 +11909,6 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.17.0.tgz", "integrity": "sha512-evtlNcpJg+cZLcnVKwsai8fExnqjGPicK7gnUtlNuzu+Fv9bI0aLpND5T44VLQtoMEnI57LoXO9XAkIXwohKrA==", "dev": true, - "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", @@ -14537,11 +14514,14 @@ } }, "node_modules/is-plain-object": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", - "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "license": "MIT", "peer": true, + "dependencies": { + "isobject": "^3.0.1" + }, "engines": { "node": ">=0.10.0" } @@ -18369,6 +18349,13 @@ "node": ">= 4" } }, + "node_modules/recast/node_modules/tiny-invariant": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", + "integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==", + "license": "MIT", + "peer": true + }, "node_modules/redent": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", @@ -18634,6 +18621,27 @@ "node": ">=10" } }, + "node_modules/restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "license": "MIT", + "peer": true, + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/restore-cursor/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", + "peer": true + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -19494,12 +19502,25 @@ "slate": ">=0.99.0" } }, - "node_modules/slate-dom/node_modules/tiny-invariant": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.1.tgz", - "integrity": "sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==", + "node_modules/slate-dom/node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", "license": "MIT", - "peer": true + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/slate/node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } }, "node_modules/smob": { "version": "1.5.0", @@ -20390,9 +20411,9 @@ } }, "node_modules/tiny-invariant": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", - "integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.1.tgz", + "integrity": "sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==", "license": "MIT", "peer": true }, diff --git a/package.json b/package.json index b2b6621..0687296 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "@eslint/js": "^9.17.0", "@tailwindcss/typography": "0.5.13", "@types/bcryptjs": "^2.4.6", + "@types/mongoose": "^5.11.97", "@types/node": "20.11.24", "@types/react": "18.2.61", "@types/react-dom": "18.2.19",