Skip to content

sinamics/typegraphql-jwt-typeorm-auth

 
 

Repository files navigation

GraphQl Mongoose Jwt Typeorm Tailwind

See Semantic-ui React version (https://github.com/Sinamics/typegraphql-jwt-typeorm-auth)

Description

  • Boiler plate project for
    • apollo-server-express
    • type-graphql
    • graphql-codegen
    • typescript
    • typeorm
    • mongodb
    • JWT

Features

  • Tailwindcss (https://tailwindcss.com/docs)
  • React Lazy Loading with Suspense
  • Express Server (port 4000)
  • type-Graphql Entry Point (/graphql)
  • Graphql Playground Page (http:https://localhost:4000/graphql)
  • Graphql Subscription
  • Typeorm Settings For MongoDB
  • Typeorm Decorators for hasRole (@hasRole(roles: [user, superuser]))
  • Basic User Entity (backend/graphql/entity/Users.ts)
  • JasonWebToken (JWT) accessToken / refreshToken cookie for authorization.
  • username Sign Up with graphql authorization error display.
  • username Sign In with graphql authorization error display

Usage

  1. Install mongodb on your computer
  2. Install npm i typescript concurrently ts-node-dev -g
  3. Clone package: git clone https://github.com/Sinamics/typegraphql-jwt-typeorm-auth.git --branch tailwind
  4. Install dependencies npm i
  5. Create .env file with the following variables on the project root folder:
SERVER_PORT=4000
ACCESS_TOKEN_SECRET=somerandomkey
REFRESH_TOKEN_SECRET=anotherrandomkey
REFRESH_TOKEN_LIFE="7 days"
ACCESS_TOKEN_LIFE="30s"
PROD_MONGO_CONNECTION=""
DEV_MONGO_CONNECTION="mongodb:https://localhost/graphqljwtauth"
  1. run the project npm start
  • This project uses graphql-codegen, and if you make any changes to the .graphql files you need to generate new hooks npm run codegen
  • If you changes any Tailwind configuration, generate new css file with npm run build:css

Login / Register Page

privatePage

Simple privatePage for testing role decorators

privatePage

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages