Skip to content

Commit

Permalink
Merge pull request #158 from Kuzuri247/master
Browse files Browse the repository at this point in the history
Export fix
  • Loading branch information
dinxsh authored Dec 22, 2024
2 parents 288db7d + 4272005 commit 894ec60
Show file tree
Hide file tree
Showing 5 changed files with 370 additions and 4,402 deletions.
2 changes: 1 addition & 1 deletion app/api/teams/create-team/route.jsx
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion app/api/teams/send-request/route.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
35 changes: 29 additions & 6 deletions model/User.js → model/User.ts
Original file line number Diff line number Diff line change
@@ -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<mongoose.Types.ObjectId>;
}

interface IUserMethods {
updatePassword(newPassword: string): Promise<void>;
}

interface IUserModel extends Model<IUser, {}, IUserMethods> {
findByEmail(email: string): Promise<IUser | null>;
}

// Created the User Schema
const userSchema = new Schema<IUser, IUserModel, IUserMethods>({
_id: {
type: Schema.Types.ObjectId,
required: true,
Expand Down Expand Up @@ -62,6 +85,6 @@ const userSchema = new Schema({
],
});

const UserModel = models.UserModel || model("UserModel", userSchema);

export default UserModel;
// Created the User Model
const UserModel = mongoose.models.UserModel || mongoose.model<IUser, IUserModel>("UserModel", userSchema);
export default UserModel;
Loading

0 comments on commit 894ec60

Please sign in to comment.