Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paalamugan/nextjs-web-oauth-project
Web OAuth Project using ChakraUI, SCSS, Next.js, React, Redux, Redux Toolkit, TypeScript, and more.
https://github.com/paalamugan/nextjs-web-oauth-project
boilerplate chakra-ui chakra-ui-react commitlint cypress docker-compose dockerfile eslint-config github-actions jestjs msw nextjs react redux redux-toolkit tailwindcss typescript vercel
Last synced: about 5 hours ago
JSON representation
Web OAuth Project using ChakraUI, SCSS, Next.js, React, Redux, Redux Toolkit, TypeScript, and more.
- Host: GitHub
- URL: https://github.com/paalamugan/nextjs-web-oauth-project
- Owner: paalamugan
- Created: 2022-11-02T18:55:45.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-07T14:26:27.000Z (about 2 years ago)
- Last Synced: 2024-05-17T20:53:43.831Z (6 months ago)
- Topics: boilerplate, chakra-ui, chakra-ui-react, commitlint, cypress, docker-compose, dockerfile, eslint-config, github-actions, jestjs, msw, nextjs, react, redux, redux-toolkit, tailwindcss, typescript, vercel
- Language: TypeScript
- Homepage: https://nextjs-web-oauth.vercel.app
- Size: 836 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Web OAuth Project
๐ Web OAuth โก๏ธ Using with Next.js, TypeScript, ChakraUI, Google OAuth, Next Auth, ESLint, Prettier, Husky, Lint-Staged, Jest, Testing Library, Commitlint, VSCode, Netlify, SCSS.
### Features
Developer experience first:
- โก [Next.js](https://nextjs.org) for Static Site Generator
- ๐ฅ Type checking [TypeScript](https://www.typescriptlang.org)
- โ Strict Mode for TypeScript and React 18
- ๐ Linter with [ESLint](https://eslint.org) (default NextJS, NextJS Core Web Vitals, Tailwind CSS and Airbnb configuration)
- ๐ Code Formatter with [Prettier](https://prettier.io)
- ๐ฆ Husky for Git Hooks
- ๐ซ Lint-staged for running linters on Git staged files
- ๐ Lint git commit with Commitlint
- ๐ Write standard compliant commit messages with Commitizen
- ๐ฆบ Unit Testing with Jest and React Testing Library
- ๐งช E2E Testing with Cypress
- ๐ก Absolute Imports using `@` prefix
- ๐ VSCode configuration: Debug, Settings, Tasks and extension for PostCSS, ESLint, Prettier, TypeScript, Jest
- ๐ค SEO metadata, JSON-LD and Open Graph tags with Next SEO
- โ๏ธ [Bundler Analyzer](https://www.npmjs.com/package/@next/bundle-analyzer)
- ๐ฑ๏ธ One click deployment with Vercel or Netlify (or manual deployment to any hosting services)
- ๐ Include a FREE minimalist theme
- ๐ฏ Maximize lighthouse scoreBuilt-in feature from Next.js:
- โ Minify HTML & SCSS
- ๐จ Live reload
- โ Cache busting### Philosophy
- Minimal code
- SEO-friendly
- ๐ Production-ready### Requirements
- Node.js 14+ and yarn 1.22+ (or npm 6+)
### Environment Variables
### Getting started
Run the following command on your local environment:
```shell
git clone https://github.com/paalamugan/nextjs-web-oauth-project.git
cd nextjs-web-oauth-project
yarn install
```**Environment configuration before we run the application**
- Option 1
- Create `.env.local` file in the root directory and add the following environment variables:
```shell
SITE_URL=http://localhost:3000 # http://localhost:3000
REGRES_API_BASE_URL=https://reqres.in/api # https://reqres.in/api
NEXTAUTH_SECRET=secret # random string
JWT_SECRET_KEY=secret # random string
NEXTAUTH_DEBUG=false # true or false
MONGODB_URI=mongodb://admin:adminpassword@localhost:27017/web-oauth # mongodb://admin:adminpassword@localhost:27017/web-oauth
GOOGLE_CLIENT_ID= # google client id
GOOGLE_CLIENT_SECRET= # google client secret
```- Option 2
- Copy .env.example to .env.local and replace the values like above.
```shell
cp -rf .env.example .env.local
```**Make sure you have MongoDB installed and running on your local environment.**
- If not then, please use the below command to run mongodb server before run the `yarn dev`.
```shell
docker-compose up -d web-oauth-mongodb
```Then, you can run locally in development mode with live reload:
```shell
yarn dev
```Open http://localhost:3000 with our favorite browser to see our project.
### Run on application using docker-compose cli (Optional)
Before run the below command, We need to have docker installed in our local machine, if not please install it from [here](https://docs.docker.com/get-docker/).
```shell
docker-compose up -d
```Run Docker Compose with our custom environment file path using below command, by default it will use `.env` file or environment variables that we used inside `docker-compose.yml` file.
```shell
docker-compose --env-file .env.local up -d
```### Folder Structure
```shell
.
โโโ README.md # README file
โโโ __mocks__ # Mocks for testing
โโโ .github # GitHub folder
โโโ .husky # Husky configuration
โโโ .vscode # VSCode configuration
โโโ public # Public assets folder
โโโ cypress # Cypress folder e2e testing
โโโ db # Init db configuration for docker-compose.yml
โโโ msw # Mock Service Worker folder
โโโ src
โ โโโ __tests__ # Unit tests folder
| โโโ api-helper # API helper folder
โ โโโ components # React components folder
โ โโโ constants # Constants folder
โ โโโ error-handlers # Error handlers folder
โ โโโ hooks # React hooks folder
โ โโโ icons # Icons folder
โ โโโ layouts # Layouts components
โ โโโ lib # Library folder
โ โโโ page-components # Nextjs Page components folder
โ โโโ pages # Next JS Pages
โ โโโ pages.test # Next JS Pages tests (this avoid test to treated as a Next.js pages)
โ โโโ providers # Providers folder
โ โโโ redux # Redux folder
โ โโโ styles # Global SCSS Styles folder
โ โโโ templates # Default template
โ โโโ utils # Utility functions
โโโ test-utils # Test utils folder
โโโ typings # Additional Typescript typings
โโโ .env.example # Environment variables example
โโโ .eslintrc # ESLint configuration
โโโ Dockerfile # Dockerfile for production
โโโ docker-compose.yml # Docker compose configuration
โโโ commitlint.config.js # Commitlint configuration
โโโ cypress.config.js # Cypress configuration
โโโ tailwind.config.js # Tailwind CSS configuration
โโโ tsconfig.json # TypeScript configuration
```### Deploy to production
You can see the results locally in production mode with:
```shell
yarn build
yarn start
```Dockerfile is available for production deployment. You can build the image with:
```shell
docker build -t web-oauth-app:latest .
```You can create an optimized production build with:
```shell
yarn build-prod
```Now, Our app is ready to be deployed. All generated files are located at `out` folder, which you can deploy with any hosting service.
### Testing
All tests are co-located with the source code inside the same directory. So, it makes it easier to find them. Unfortunately, it is not possible with the `pages` folder which is used by Next.js for routing. So, what is why we have a `pages.test` folder to write tests from files located in `pages` folder.
### Deploy to Vercel
Deploy this Web OAuth on Vercel in one click:
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/paalamugan/nextjs-web-oauth-project)
### VSCode information (optional)
If you are VSCode users, you can have a better integration with VSCode by installing the suggested extension in `.vscode/extension.json`. The starter code comes up with Settings for a seamless integration with VSCode. The Debug configuration is also provided for frontend and backend debugging experience.
With the plugins installed on your VSCode, ESLint and Prettier can automatically fix the code and show you the errors. Same goes for testing, you can install VSCode Jest extension to automatically run your tests and it also show the code coverage in context.
Pro tips: if you need a project wide type checking with TypeScript, you can run a build with Cmd + Shift + B on Mac.
### Tips
- Generate base64 secret key with below command
```sh
openssl rand -base64 32
```