Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Cleaning codebase #201

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion database/conn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ mongoose.connect(process.env.MONGO_URL, {
}).catch((e) => {
console.log("MongoDB not connected");
console.log(e);
})
})
18 changes: 8 additions & 10 deletions database/registers.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@

const mongoose = require("mongoose");
const chatSchema = new mongoose.Schema({
name: {
type: String,

type: String,
},
message: {
type: String,
required: true
required: true,
type: String,
},
email: {
type: String,
required: true
required: true,
type: String,
},
time: {
type: String
type: String,
}
});
const Message = new mongoose.model("message", chatSchema);
module.exports = Message;

const Message = new mongoose.model("message", chatSchema);
module.exports = Message;
4 changes: 3 additions & 1 deletion database/signupschema.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ const userSchema = new mongoose.Schema({
minlength: [6, "Minimum length should be 6 character"],
},
});

userSchema.pre("save", async function (next) {
const salt = await bcrypt.genSalt();
this.password = await bcrypt.hash(this.password, salt);
next();
})

const User = new mongoose.model("user", userSchema);
module.exports = User;
module.exports = User;
Loading