Skip to content

meleshyn/nestjs-jwt-sequelize-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

API Demonstration

postman.mp4

Getting Started

Clone the Repository

git clone https://github.com/meleshyn/nestjs-jwt-sequelize-app.git
cd nestjs-jwt-sequelize-app

Install Dependencies

npm install

Starting the MySQL Database using Docker:

docker run --rm --name mysql-nest-dev \
  -e MYSQL_ROOT_PASSWORD=root \
  -e MYSQL_DATABASE=dev \
  -p 3306:3306 \
  -d mysql:latest
  • Note: The -rm flag ensures the container is removed after stopping, deleting all data.

Running Database Migrations

npm run migrate

Starting the Application

npm run start

API Documentation

API Versioning

  • Base URL: http://localhost:3000/api/v1

Authentication

  • JWT Tokens: Pass the JWT token in the Authorization header as Bearer <token>.

Endpoints

Register User

  • URL: /register

  • Method: POST

  • Description: Registers a new user.

  • Request Body:

    {
      "name": "John Doe",
      "email": "john.doe@example.com",
      "phone": "1234567890",
      "password": "securepassword"
    }
  • Response:

    {
      "id": 1,
      "name": "John Doe",
      "email": "john.doe@example.com",
      "phone": "1234567890"
    }

Login User

  • URL: /login

  • Method: POST

  • Description: Logs in a user and returns an access token.

  • Request Body:

    {
      "email": "john.doe@example.com",
      "password": "securepassword"
    }
  • Response:

    {
      "access_token": "<JWT_TOKEN>"
    }

Get User Data

  • URL: /user

  • Method: GET

  • Description: Retrieves authenticated user data.

  • Headers:

    Authorization: Bearer <JWT_TOKEN>
  • Response:

    {
      "id": 1,
      "name": "John Doe",
      "email": "john.doe@example.com",
      "phone": "1234567890"
    }

About

๐Ÿš€ A NestJS server application with JWT authentication and Sequelize ORM

Topics

Resources

Stars

Watchers

Forks