DEV Community

Smruti Ranjan Rana
Smruti Ranjan Rana

Posted on

Omega App: Server

Packages we need.

"@sendgrid/mail": "^7.2.4",
"bcrypt": "^5.0.0",
"cookie-parser": "~1.4.4",
"cors": "^2.8.5",
"debug": "~2.6.9",
"dotenv": "^8.2.0",
"express": "~4.16.1",
"express-validator": "^6.6.1",
"googleapis": "^40.0.1",
"http-errors": "~1.6.3",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.10.2",
"morgan": "~1.9.1",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0"
Enter fullscreen mode Exit fullscreen mode

Our Endpoints

  • /api: API_ENDPOINT
  • /api/docs: API_DOCS
  • /api/auth: AUTH_ENDPOINT
  • /signup : AUTH_SIGNUP
  • /login : AUTH_LOGIN
  • /verify/:token : AUTH_VERIFY_EMAIL
  • /api/auth/verify/: AUTH_VERIFY_FULL
  • /resend : AUTH_VERIFY_EMAIL_RESEND
  • /recover : AUTH_RECOVER
  • /reset/:token : AUTH_CHECK_RESET_LINK
  • /reset/:token : AUTH_RESET
  • /api/auth/reset/ : AUTH_RESET_FULL

  • /api/user : USER_ENDPOINT

  • /update : USER_UPDATE

  • /updatePassword : USER_UPDATE_PASSWORD

  • /deleteAccount : USER_DELETE_ACCOUNT

  • /resetPassword : CLIENT_RESET_PASSWORD_PATH

  • /verifyEmail : CLIENT_EMAIL_VERIFICATION_PATH

  • /api/subscriptions : SUBSCRIPTIONS_ENDPOINT

  • /add/google : SUBSCRIPTIONS_ADD_GOOGLE

  • /add/google/callback : SUBSCRIPTIONS_ADD_GOOGLE_CALLBACK

  • /updateSubscription : SUBSCRIPTIONS_UPDATE_SUBSCRIPTION

  • /api/spreadsheets : SPREADSHEETS_ENDPOINT

Environment variables

* API_ENDPOINT=<API Endpoint ex: /api>
* SERVER_ROUTE=<Inital route of server after domain name. ex: /app>
* CLIENT_URL=<Client URL ex: http://localhost:3000>
* MONGO_URI=<MongoDB URI>
* JWT_SECRET=<Random String for JWT Secret>
* SENDGRID_API_KEY=<Sengrid API Key>
* SENDGRID_FROM_EMAIL=<Email of the sender>
* GOOGLE_CLIENT_ID=<Google Client ID>
* GOOGLE_CLIENT_SECRET=<Google Client Secret>
Enter fullscreen mode Exit fullscreen mode

Models

  • EmailVerificationToken.model.js : Email verification token model
  • User.model.js : User model

Middlewares

We need the below middlewares.

  • jwt.js: Handle JWT Token
  • validate.js: Handle email, username, password validation
  • authenticated.js: Handle the authentication

Controllers

  • auth.js : Handle all authtication requests
  • user.js : Handle all User related requests
  • subscriptions.js : Handle all subscriptions (Google Accounts) related requests
  • spreadsheets.js : Handle all spreadsheets related requests.

Top comments (0)