An open API service indexing awesome lists of open source software.

https://github.com/konradmi/auth-nodejs-mysql

Boilerplate for server side authentication with node.js, passport and MySQL
https://github.com/konradmi/auth-nodejs-mysql

authentication express jwt mysql nodejs passportjs

Last synced: 3 months ago
JSON representation

Boilerplate for server side authentication with node.js, passport and MySQL

Awesome Lists containing this project

README

          

# auth-nodejs-mysql README

## Setup

### Database

To save your time and frustration I've prepared a vagrantfile with a test database

To run the database locally:

Install `mysql`

Install `virtualbox`

Install `vagrant`

Install `vagrant-triggers`

Run `vagrant up`

A brand new instance of MySQL should be listening on port 3310

### Api

Install `nvm`

Install node: `nvm install 6`

Install dependencies: `npm install`

Start api: `npm run start:dev`

Api listens on port 4000 by default, hit http://localhost:4000/health to see if it's live and kicking

## API Endpoints:

`POST /signup` - it accepts login and password. Once it's been verified that there's no user with the given login in the database, the login and hashed password is saved in the database and a JWT token is created and sent back to the user

`POST /singin` - it accepts login and password. It checks if the login and password are ok and a JWT token is sent back to the user

`GET /` - in order to access the route you have to include the JWT token in the `authorization` header in the request.