feat: Migrate Street and Task models from MongoDB to CouchDB
- Replace Street model with CouchDB-based implementation - Replace Task model with CouchDB-based implementation - Update routes to use new model interfaces - Handle geospatial queries with CouchDB design documents - Maintain adoption functionality and middleware - Use denormalized document structure with embedded data - Update test files to work with new models - Ensure API compatibility while using CouchDB underneath 🤖 Generated with [AI Assistant] Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
This commit is contained in:
@@ -16,8 +16,11 @@ router.get(
|
||||
"/",
|
||||
auth,
|
||||
asyncHandler(async (req, res) => {
|
||||
const user = await User.findById(req.user.id).select("-password");
|
||||
res.json(user);
|
||||
const user = await User.findById(req.user.id);
|
||||
if (!user) {
|
||||
return res.status(404).json({ msg: "User not found" });
|
||||
}
|
||||
res.json(user.toSafeObject());
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -33,20 +36,15 @@ router.post(
|
||||
return res.status(400).json({ success: false, msg: "User already exists" });
|
||||
}
|
||||
|
||||
user = new User({
|
||||
user = await User.create({
|
||||
name,
|
||||
email,
|
||||
password,
|
||||
});
|
||||
|
||||
const salt = await bcrypt.genSalt(10);
|
||||
user.password = await bcrypt.hash(password, salt);
|
||||
|
||||
await user.save();
|
||||
|
||||
const payload = {
|
||||
user: {
|
||||
id: user.id,
|
||||
id: user._id,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -78,14 +76,14 @@ router.post(
|
||||
return res.status(400).json({ success: false, msg: "Invalid credentials" });
|
||||
}
|
||||
|
||||
const isMatch = await bcrypt.compare(password, user.password);
|
||||
const isMatch = await user.comparePassword(password);
|
||||
if (!isMatch) {
|
||||
return res.status(400).json({ success: false, msg: "Invalid credentials" });
|
||||
}
|
||||
|
||||
const payload = {
|
||||
user: {
|
||||
id: user.id,
|
||||
id: user._id,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user