Skip to content
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: 2 additions & 0 deletions server/config/nodeMailer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const transporter = nodemailer.createTransport({
host: "smtp-relay.brevo.com",
port: 587,
secure: false, // Must be false for port 587
pool: true,
maxConnections: 5,
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS,
Expand Down
5 changes: 3 additions & 2 deletions server/controllers/authControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export const register = async (req, res) => {
subject: "Welcome to MeetOnMemory!",
text: `Welcome to MeetOnMemory, ${name}! Your account has been successfully created.`,
};
await transporter.sendMail(mailOptions);
res.json({ success: true, message: "Registration successful" });

return res.json({ success: true, message: "Registration successful" });
transporter.sendMail(mailOptions).catch((err) => {
console.error("Welcome email failed to send:", err.message); });
} catch (error) {
console.error("Register error:", error);
res.json({ success: false, message: error.message });
Expand Down
14 changes: 2 additions & 12 deletions server/middleware/userAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@ import userModel from "../models/userModel.js";

const userAuth = async (req, res, next) => {
try {
console.log("=================================");
console.log("Origin:", req.headers.origin);
console.log("Cookies:", req.cookies);
console.log("Authorization:", req.headers.authorization);
console.log("=================================");

const token =
req.cookies?.token ||
req.header("Authorization")?.replace("Bearer ", "");

console.log("Token Found:", token ? "YES" : "NO");

if (!token) {
return res.status(401).json({
success: false,
Expand All @@ -24,9 +16,7 @@ const userAuth = async (req, res, next) => {

const decoded = jwt.verify(token, process.env.JWT_SECRET);

console.log("Decoded JWT:", decoded);

const user = await userModel.findById(decoded.id).select("-password");
const user = await userModel.findById(decoded.id).select("-password").lean();

if (!user) {
return res.status(404).json({
Expand All @@ -48,4 +38,4 @@ const userAuth = async (req, res, next) => {
}
};

export default userAuth;
export default userAuth;
21 changes: 10 additions & 11 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ app.use("/api/policies", policyRoutes);
app.use("/api/analytics", analyticsRoutes);
app.use("/api/gemini", geminiRoutes);

// ================================
// VECTOR STORE INIT
// ================================
try {
await initVectorStore();
console.log("✅ Vector store initialized");
} catch (error) {
console.error("⚠️ Vector store initialization failed:", error.message);
}

// ================================
// START SERVER
// ================================
Expand All @@ -118,6 +108,15 @@ const server = app.listen(PORT, () => {
console.log(`🌐 Allowed Origins: ${allowedOrigins.join(", ")}`);
});

// ================================
// VECTOR STORE INIT (non-blocking)
// ================================
initVectorStore()
.then(() => console.log("✅ Vector store initialized"))
.catch((error) => {
console.error("⚠️ Vector store initialization failed:", error.message);
});

// ================================
// SOCKET.IO
// ================================
Expand Down Expand Up @@ -158,4 +157,4 @@ process.on("SIGINT", () => {
server.close(() => {
process.exit(0);
});
});
});