I noticed theres a bit code repetition in your routers / handlers.
This pops up a few times:
if (req.headers.cookie){
let { jwt } = parse(req.headers.cookie)
verify(jwt, process.env.JWT_SECRET, (err, decoded)=>{
// some code here
}
And also the JWT verifying logic is split between the router/handler files. It might be more consistent to keep it to one or the other.
Another thing you could consider is having some reusable functions for things like bcrypt / JWTs (perhaps in a separate utils file), which you can pull in when needed... :)
I noticed theres a bit code repetition in your routers / handlers.
This pops up a few times:
And also the JWT verifying logic is split between the router/handler files. It might be more consistent to keep it to one or the other.
Another thing you could consider is having some reusable functions for things like bcrypt / JWTs (perhaps in a separate
utilsfile), which you can pull in when needed... :)