Giter Site home page Giter Site logo

nestjs-jwt-auth's Introduction

Description

NestJS JWT authentication service using NestJS, Docker and MySQL. It can be used as a JWT Auth Microservice or can be used as starter repository for an API project.

Setup

  • Pre-Requisite

    • For dockerized environment we need
      • docker,
      • docker-compose installed.
    • To run API server without Docker we need
      • Node.js (>= 10.13.0) installed,
      • Dependency manager yarn installed,
      • Nestjs CLI nest installed (follow here) and
      • MySQL server running
  • Configuration

    • In application root, create .env copying form example env file env.example.
    • An example env file contains
      • MySQL credentials for the dockerized environment. For non-docker setup, update MySQL credentials here.
      • Password encription salt and JWT secret key values. Change them with some secret values.
  • Run API

    • For Docker: Up docker-compose, this will create a docker container with the database with the given name in env.
    $ docker-compose up --build
    
    • For non-docker run install dependencies and run nodejs API server
    $ yarn
    $ yarn run start
    
  • API Documentation

    $ yarn run start:api-doc
    
  • API With above steps done, API should be up and running

Migration

  • TypeORM CLI used to manage DB migration. ORM configurations are available in the orm.config.ts file.
  • Migration auto-synchronization is set to true in development environment, and false in other environments.
  • To create a new empty migration file, use migration:create command.
$ yarn migration:create -n createUsers
  • TypeORM can generate a migration file from changed entity files comparing with the database. To generate a populated migration file from entity files, use migration:generate command
$ yarn migration:generate -n createUsers
  • To run DB migration:
$ yarn migration:run
  • To rollback migration:
$ yarn migration:revert

Read more about TypeORM migration [here][https://typeorm.io/#/migrations]

Running Test

yarn test or npm run test

Contribution Guidelines

Feel free to submit issues or PRs. You can checkout the coding style guide before submitting the PRs. Link is here.

Stay in touch

nestjs-jwt-auth's People

Contributors

0hsn avatar asad-mlbd avatar dependabot[bot] avatar saad-amjad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nestjs-jwt-auth's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.