Skip to content

Commit 26c4dac

Browse files
committed
implement google oauth, built user model
1 parent 1d5635b commit 26c4dac

15 files changed

+668
-32
lines changed

.env.example

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
PORT=
2-
MONGO_URI=
2+
MONGO_URI=
3+
SECRET=
4+
JWT_SECRET=
5+
GOOGLE_CLIENT_ID=
6+
GOOGLE_CLIENT_SECRETE=
7+
GOOGLE_CALLBACK_URL=
8+
FRONTEND_URL=
9+
BACKEND_URL=

README.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A comprehensive and professional Node.js backend boilerplate designed for buildi
1515
3. [To-Do List](#to-do-list)
1616
4. [Getting Started](#getting-started)
1717
5. [Project Structure](#project-structure)
18-
6. [Usage](#usage)
18+
6. [Authentication Setup](#authentication-setup)
1919
7. [Code Quality Automation](#code-quality-automation)
2020
8. [Configuration](#configuration)
2121
9. [Testing](#testing)
@@ -146,12 +146,41 @@ node-backend-boilerplate/
146146

147147
---
148148

149-
## **Usage**
149+
## **Authentication Setup**
150150

151151
### **Google Authentication**
152152

153+
1. **Set Up Google OAuth2 application**
154+
155+
- Go to the [Google Cloud Console](https://console.cloud.google.com/).
156+
- Create a new project and enable the "OAuth2.0 API".
157+
- Set up an OAuth consent screen and create credentials for a Web Application.
158+
- Add authorized redirect URIs (e.g., `http://localhost:5000/auth/google/callback`).
159+
160+
2. **Environment Variables**
161+
Update your `.env` file with the following variables:
162+
163+
```plaintext
164+
GOOGLE_CLIENT_ID=<Your Google Client ID>
165+
GOOGLE_CLIENT_SECRET=<Your Google Client Secret>
166+
GOOGLE_CALLBACK_URL=http://localhost:5000/auth/google/callback
167+
```
168+
153169
### **Phone Code Authentication**
154170

171+
1. **Set Up Twilio Account**
172+
173+
- Go to the [Twilio Console](https://www.twilio.com).
174+
- Create a Messaging Service and note the SID.
175+
176+
2. **Environment Variables**
177+
Update your `.env` file with the following variables:
178+
```plaintext
179+
TWILIO_ACCOUNT_SID=<Your Twilio Account SID>
180+
TWILIO_AUTH_TOKEN=<Your Twilio Auth Token>
181+
TWILIO_PHONE_NUMBER=<Your Twilio Phone Number>
182+
```
183+
155184
---
156185

157186
## **Code Quality Automation**

eslint.config.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export default [
1111
files: ['**/*.{js,mjs,cjs,ts}'],
1212
rules: {
1313
'no-console': 'warn',
14+
'@typescript-eslint/no-namespace': 'off',
15+
'@typescript-eslint/no-empty-object-type': 'off',
1416
},
1517
},
1618
];

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@
2626
"license": "MIT",
2727
"devDependencies": {
2828
"@eslint/js": "^9.15.0",
29+
"@types/bcryptjs": "^2.4.6",
30+
"@types/cookie-parser": "^1.4.7",
31+
"@types/cors": "^2.8.17",
2932
"@types/express": "^5.0.0",
33+
"@types/express-session": "^1.18.0",
34+
"@types/jsonwebtoken": "^9.0.7",
35+
"@types/passport": "^1.0.17",
36+
"@types/passport-google-oauth20": "^2.0.16",
37+
"@types/passport-local": "^1.0.38",
3038
"@types/supertest": "^6.0.2",
3139
"@types/swagger-jsdoc": "^6.0.4",
3240
"@types/swagger-ui-express": "^4.1.7",
@@ -42,9 +50,17 @@
4250
"winston": "^3.17.0"
4351
},
4452
"dependencies": {
53+
"bcryptjs": "^2.4.3",
54+
"cookie-parser": "^1.4.7",
55+
"cors": "^2.8.5",
4556
"dotenv": "^16.4.5",
4657
"express": "^4.21.1",
58+
"express-session": "^1.18.1",
59+
"jsonwebtoken": "^9.0.2",
4760
"mongoose": "^8.8.2",
61+
"passport": "^0.7.0",
62+
"passport-google-oauth20": "^2.0.0",
63+
"passport-local": "^1.0.0",
4864
"swagger-jsdoc": "^6.2.8",
4965
"swagger-ui-express": "^5.0.1",
5066
"ts-node": "^10.9.2"

0 commit comments

Comments
 (0)