Giter Site home page Giter Site logo

rodrigoferrobr / nestjs-rest-api-boilerplate-with-jwt-and-mysql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chaksaray/nestjs-rest-api-boilerplate-with-jwt-and-mysql

0.0 0.0 0.0 123 KB

NestJS RESTful API Boilerplate with JWT Auth and Mysql, it covers the basic needs, and boilerplate work of a new project.

Shell 4.73% JavaScript 2.56% TypeScript 91.46% Dockerfile 1.24%

nestjs-rest-api-boilerplate-with-jwt-and-mysql's Introduction

NestJS-REST-API-Boilerplate-with-JWT-and-Mysql

NestJS RESTful API Boilerplate with JWT Authentication and backend Mysql. It covers the basic needs, and boilerplate work of a new project. It promotes the best practices that follow the clean architecture.

The Rest API provides the following features right out of the box:

  • Endpoints in the widely accepted format
  • Standard CRUD operations
  • JWT-based authentication
  • Middleware
  • Environment dependent application configuration
  • Logging
  • Error handling
  • Database migration and seeding
  • Data validation
  • Full test cover
  • Cache(Redis) integration
  • Docker compose
  • API doc using swagger as yaml file

Getting Started

Docker is needed if you want to try the API without setting up your own database server.

Run the following commands to start experiencing this API:

# download the starter kit
git clone https://github.com/chaksaray/NestJS-REST-API-Boilerplate-with-JWT-and-Mysql.git

cd NestJS-REST-API-Boilerplate-with-JWT-and-Mysql

# start a Mysql database server, redis cache & running project in a Docker container
docker-compose up -d

# run migrate database
$ bin/migrate

# revert migration
$ bin/migration-revert

# generate migration file
$ bin/migration-generate ${NameMigration}

# revert migration
$ bin/seed

# test
$ bin/test

# watch test
$ bin/test-watch

At this time, you have a REST API server running at http://127.0.0.1:3000. It provides the following endpoints:

  • GET /: show a welcome page
  • POST /v1/login: authenticates a user and generates a JWT
  • GET /v1/users: returns a paginated list of the albums
  • GET /v1/users/:id: returns the detailed information of an user
  • POST /v1/users: creates a new user
  • PUT /v1/users/:id: updates an existing user
  • DELETE /v1/users/:id: deletes a user

Project Layout

This API uses the following project layout:

.
├── src
│   ├── auth             authentication feature
│   ├── cache            redis cache is implemented here
│   ├── domains          contains the folders of the logic for instance, user, post ...
│   ├── scripts          useful scripts
│   ├── log.config.ts    config log
│   ├── ormconfig.service.ts    orm config for our service
|   └── main.ts          where the app is run
├── bin                  useful commands
├── config               database & redis cache configuration
├── docs                 api doc, swagger.yml
├── logs                 contain error & info log
├── mysql
|   ├── migrations       migration files
|   ├── seeds            seeding database data
│   └── init-db.sql      create database
├── tests
|   ├── integration      integration test
│   └── unit             unit test
└── .env                 environment variables

nestjs-rest-api-boilerplate-with-jwt-and-mysql's People

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.