/node-sql-user-manager

Simple api to manage users with authentication.

Primary LanguageHTMLMIT LicenseMIT

Node api with MySQL DB connection and JWT auth

Built on node-mysql-boilerplate to accomodate a simple user management api with simple jwt authentication.

PreRequisite

  • NodeJS
  • Mysql
  • Express

Used Packages

1. MYSQL

 npm install mysql

2. Express

npm install express

4. JWT

npm install jsonwebtoken

7. nodemailer

npm install nodemailer  

9. bcrypt

npm install bcrypt  
  • bcrypt will encrypt your password throughing hashing so your password won't store as plain text .know more about bcrypt
  • To Know more about nodemailer check here

Get Started

  1. $ git clone http://github.com/anankitpatil/node-sql-user-manager.git
  2. $ npm install
  3. Launch Enviornment:
    • $ npm start
  4. Api url
    • open http://localhost:9890

API Usage

  1. login route - http://localhost:9890/api/login
    • pass json object contain username and password.
  2. other crud route are in secureApi - localhost:9890/secureApi/user.
    • In all GET, PUT, DELETE and POST request pass token in header which you get in login response.

Example object for login request -

{
    "username":"test",
    "password":"testpass"
}

For Other Crud request -

{
   "name":"username",
   "age:11,
   "state":"statename",
   "country":"countryname"
}

Note: You have to pass token for each request as header which you will get in login response.

Features

  • To perform basic operation all Create, Fetch, Delete and Update functionality.
  • Used Express framework to obtain required operations.
  • Used Express router to route endpoint path.
  • Used JWT Token for security and authentication of API.
  • MVC structure in which Route, Service and Model layer.
  • Used Connection Pooling which lead to reduce number of conncetion at any point of time and reduce stress in DB which leads to better availability and Performance of DB.
  • Used common error structure format for all type of error throwing in Application.
  • nodemailer is used to send mail over SMTP. as for i now used for sending mail if error comes.
  • bcrypt is used to encrypt your password through salt and hashing technique and which won't store password as plain text in database.