Google OAuth using TypeScript, Express.js, Passport.js & MongoDB
OAuth (stands for Open Authorization) is a standard protocol that allows an app to get delegated access to resources of a 3rd party service like Google, Facebook, Github, etc. OAuth is one of the most popular ways to authorize users in modern web app...
samippoudel.hashnode.dev16 min read
I think to connect to mongoose we might need to connect this way.
mongoose.connect(MONGO_URI).then(() => { console.log("connected to mongodb"); }).catch((e) => { console.log("could not connect to mongodb", e); });We would als need to install
@types/cookie-sessionAnd I think the logout function should be implemented this way
router.get("/logout", (req: Request, res: Response) => { req.logout(function(err) { if (err) { console.error('error when logging out', err); } res.redirect("/"); }); });