Added backend folder structure.

This commit is contained in:
2025-02-22 12:55:06 +05:30
parent fc8c089ade
commit 793e6c2009
18 changed files with 3215 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
const mongoose = require("mongoose");
const meetingSchema = new mongoose.Schema(
{
meetingDate: {
type: Date,
required: true,
},
meetingTime: {
type: String,
required: true,
},
mentorName: {
type: String,
required: true,
},
mentiName: {
type: String,
required: true,
},
mentorId: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true,
},
mentiId: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true,
},
status: {
type: String,
default: "Pending",
},
amount: {
type: Number,
required: true,
},
paymentStatus: {
type: "Status",
default: "Pending",
},
},
{
timestamps: true,
}
);
const Meeting = mongoose.model("Meeting", meetingSchema);
module.exports = Meeting;
+111
View File
@@ -0,0 +1,111 @@
const mongoose = require("mongoose");
const bcrypt = require("bcrypt");
const jwt = require("jsonwebtoken");
const crypto = require("crypto");
const userSchema = new mongoose.Schema(
{
name: {
type: String,
required: [true, "Please Enter your name"],
maxLength: [30, "Please Enter the valid name"],
minLength: [2, "Name should have more than 5 characters"],
},
skills: [
{
type: String,
},
],
uniqueRole: {
type: String,
},
country: {
type: String,
},
description: {
type: String,
},
email: {
type: String,
required: true,
unique: true,
lowerCase: true,
},
password: {
type: String,
required: true,
minLength: [6, "Password should have more than 6 characters"],
},
avatar: {
type: String,
default: "/images/profile.jpeg",
},
role: {
type: String,
default: "user",
},
mainInterest: [
{
type: String,
},
],
documents: [
{
type: String,
},
],
meettingFees: {
type: Number,
},
resetPasswordToken: String,
resetPasswordExpiry: Date,
},
{
timestamps: true,
}
);
userSchema.pre("save", async function (next) {
if (!this.isModified("password")) return next();
this.password = await bcrypt.hash(this.password, 10);
return next();
});
userSchema.methods.isPasswordCorrect = async function (password) {
return await bcrypt.compare(password, this.password);
};
userSchema.methods.generateRefreshToken = async function () {
return await jwt.sign(
{
_id: this._id,
email: this.email,
},
process.env.REFRESH_TOKEN_SECRET
// {
// expiresIn: process.env.REFRESH_TOKEN_EXPIRY,
// }
);
};
userSchema.methods.getResetPassword = async function () {
// Generating token
const resetToken = await crypto.randomBytes(20).toString("hex");
// Hashing and adding reset password token to userschema
this.resetPasswordToken = crypto
.createHash("sha256")
.update(resetToken)
.digest("hex");
this.resetPasswordExpiry = Date.now() + 15 * 60 * 1000;
return resetToken;
};
const User = mongoose.model("User", userSchema);
module.exports = User;