Skip to content

MartinYounghoonKim/nodejs-authenticate-jwt-vuejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Authentication App

Node.js Stack

  • Mysql
  • Express server
  • Forever
  • Nodemon
  • Redis

Vuejs Stack

  • Vue@2.5.2
  • Vue Router@3.0.1

Features

  • ---------- Essentials ----------
  • Seperate frontend and backend server
  • ---------- Backend server ----------
  • Signin
  • Signup
  • Signout
  • JWT authenticate
  • Store refresh token in redis
  • Read logic with permission
  • Create logic with permission
  • Delete logic with permission
  • Update logic with permission
  • ---------- Frontend server ----------
  • handling jwt token with vuex
  • handling Authenticate
    • Signup
    • Signin
    • Signout
  • management toast popup about server's response

Getting started

  1. install module
# install frontend
$ cd frontend
$ npm install

Frontend set up

  1. install module
# install frontend
$ cd frontend
$ npm install
  1. start frontend server
$ npm start

Backend set up

$ cp ./backend/.env.sample ./backend/.env 
  1. Setting database
CREATE TABLE `users` (
      `index` int(11) NOT NULL AUTO_INCREMENT,
      `user` varchar(50) NOT NULL,
      `role` varchar(50) NOT NULL,
      `position` varchar(50) NOT NULL,
      `password` varchar(80) DEFAULT NULL,
  PRIMARY KEY (`index`)
) ENGINE=InnoDB AUTO_INCREMENT=8;

CREATE TABLE boards (
      `index` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Board item`s primary key',
      `user` varchar(50) NOT NULL COMMENT 'Creator',
      `upk` int(11) NOT NULL COMMENT 'Creator`s primary key',
      `title` varchar(50) NOT NULL COMMENT 'Board item`s title',
      `content` mediumtext NOT NULL COMMENT 'Board item`s content',
      `regdate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Board item`s regdate',
      `editdate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Board item`s edit date',
  PRIMARY KEY (`index`)
  
)
COLLATE='utf8_general_ci' ENGINE=InnoDB AUTO_INCREMENT=1;
  1. Start redis cli server on background
$ redis-server &
  1. Install all backend dependencies
$ cd backend && npm install
  1. Edit database.config.js
$ vi backend/config/database.config.js

# After that setting git command
$ git update-index --assume-unchanged backend/config/database.config.js
  1. Make logs directory for loggin backend server
# Directory: /backend
$ mkdir logs && cd logs && touch err.log & touch forever.log & touch out.log 
  1. Serve the app
$ node ./bin/www

About

💡JWT Authentication sample code with nodejs and vuejs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages