-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Abhinav Bhattarai
committed
Jan 21, 2021
1 parent
1bbdeb8
commit 42add66
Showing
6 changed files
with
74 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[0118/163331.464:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[0119/093126.682:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[0121/094456.011:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[0121/162819.573:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,39 @@ | ||
import express from "express"; | ||
import redis from 'redis'; | ||
import RegistrationModel from "../Models/register-model"; | ||
// import express from "express"; | ||
// import redis from 'redis'; | ||
// import RegistrationModel from "../Models/register-model.js"; | ||
|
||
const caches = redis.createClient(); | ||
const router = express.Router(); | ||
// const caches = redis.createClient(); | ||
// const router = express.Router(); | ||
|
||
router.put("/:type/:Username", (req, res) => { | ||
const type = req.params.type; | ||
// router.put("/:Username", (req, res) => { | ||
|
||
RegistrationModel.findOne({Username: req.params.Username}).exec().then((response)=>{ | ||
if(response){ | ||
const error = {error: true}; | ||
if (type === "both") { | ||
const ProfilePicture = req.body.ProfilePicture; | ||
const Username = req.body.Username; | ||
if(ProfilePicture && Username){ | ||
response.Username = Username; | ||
response.ProfilePicture = ProfilePicture; | ||
}else{ | ||
return res.json(error) | ||
} | ||
} | ||
|
||
else if (type === "profile") { | ||
const ProfilePicture = req.body.ProfilePicture; | ||
if(ProfilePicture){ | ||
response.ProfilePicture = ProfilePicture; | ||
}else{ | ||
return res.json(error); | ||
} | ||
} | ||
|
||
else { | ||
const Username = req.body.Username; | ||
if(Username){ | ||
response.Username = Username; | ||
}else{ | ||
return res.json(error) | ||
} | ||
} | ||
// RegistrationModel.findOne({Username: req.params.Username}).exec().then((response)=>{ | ||
// if(response){ | ||
// const error = {error: true}; | ||
// const ProfilePicture = req.body.ProfilePicture; | ||
// const Username = req.body.Username; | ||
// if(ProfilePicture && Username){ | ||
// if(response.Username !== Username && Username.length >= 4){ | ||
// response.Username = Username; | ||
// } | ||
// if(response.ProfilePicture !== ProfilePicture && ProfilePicture.length >= 10){ | ||
// response.ProfilePicture = ProfilePicture; | ||
// } | ||
// caches.del(`profile-pic/${req.params.Username}`, ()=>{ | ||
// caches.set(`profile-pic/${req.body.Username}`, response.ProfilePicture, ()=>{ | ||
// response.save().then(()=>{ | ||
// return res.json({updated: true}); | ||
// }).catch(()=>{ | ||
// return res.json(error) | ||
// }) | ||
// }) | ||
// }) | ||
// }else{ | ||
// return res.json(error) | ||
// } | ||
// } | ||
// }) | ||
|
||
if(type === "both" || type === "profile"){ | ||
if(type === "both"){ | ||
caches.del(`profile-pic/${req.params.Username}`, ()=>{ | ||
caches.set(`profile-pic/${req.body.Username}`, response.ProfilePicture, ()=>{ | ||
response.save().then(()=>{ | ||
return res.json({updated: true}); | ||
}).catch(()=>{ | ||
return res.json(error) | ||
}) | ||
}) | ||
}) | ||
}else{ | ||
caches.set(`profile-pic/${req.params.Username}`, response.ProfilePicture, ()=>{ | ||
response.save().then(()=>{ | ||
return res.json({updated: true}); | ||
}).catch(()=>{ | ||
return res.json(error) | ||
}) | ||
}) | ||
} | ||
}else{ | ||
response.save().then(()=>{ | ||
return res.json({updated: true}); | ||
}).catch(()=>{ | ||
return res.json(error) | ||
}) | ||
} | ||
// }); | ||
|
||
} | ||
}) | ||
|
||
}); | ||
|
||
export default router; | ||
// export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters