Skip to content

leandronorcio/notes-oauth2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Notes - OAuth 2.0

A minimal notes app where users can login using their Github, Google and Facebook accounts.

About this project

This project is a monorepo that contains both the client and server code. The client is a PWA built with Vite and uses React Router, and the server is an Express application. The data is stored in a PostgreSQL database.

It conforms to the OAuth 2.0 (and OpenID Connect) standards, upon successful consent from the user to access their basic data from the OAuth 2.0 providers, the backend checks whether the user's OAuth provider's ID already exists in the database, if not, we sign them up, otherwise we log them in.

Upon successful login, the backend sets an HttpOnly cookie that contains a JSONWebToken (JWT), the JWT is used to authorize users access to the app.

Full technology stack

  • Frontend: TypeScript, React, React Router, ShadCN UI, TailwindCSS
  • Backend: TypeScript, Express.js, PostgreSQL, JSONWebToken, OAuth 2.0, OpenID Connect

Deployment

Both the client and server are deployed to an EC2 instance (Amazon Linux 2023), you can deploy this anywhere you want on any Node.js host provider. To deploy on EC2, follow these steps.

  1. Create a .env.production of the client project, and config.env of the server project, refer to the respective example configuration files.
  2. Create client credentials on each OAuth providers (Github, Google and Facebook) and copy them to the environment variables of the server project.
  3. Setup a PostgreSQL database, and copy its credentials to the environment variables of the server project.
  4. Run npm run pm2 on both the client and server projects.