---
title: "Comment by Dipta on \"Google OAuth using TypeScript, Express.js, Passport.js &  MongoDB\" | Hashnode"
description: "I think to connect to mongoose we might need to connect this way. mongoose.connect(MONGO_URI).then(() = &gt; { console.log( &quot;connected to mongodb&quot; );"
url: "https://hashnode.com/posts/google-oauth-using-typescript-expressjs-passportjs-and-mongodb/617a7f926584fe6ae5985c6d/comment/6590172e8b01e644a2626b4b"
---

[Discussion](https://hashnode.com/posts/google-oauth-using-typescript-expressjs-passportjs-and-mongodb/617a7f926584fe6ae5985c6d)

Comment [Google OAuth using TypeScript, Express.js, Passport.js & MongoDB](https://hashnode.com/posts/google-oauth-using-typescript-expressjs-passportjs-and-mongodb/617a7f926584fe6ae5985c6d)

[Dipta](https://hashnode.com/@Dipta10)

[Dec 30, 2023](https://hashnode.com/posts/google-oauth-using-typescript-expressjs-passportjs-and-mongodb/617a7f926584fe6ae5985c6d/comment/6590172e8b01e644a2626b4b)

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-session`

And 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("/");
  });

});
```
