Skip to content

Latest commit

 

History

History
57 lines (33 loc) · 1.34 KB

README.md

File metadata and controls

57 lines (33 loc) · 1.34 KB

Simple Node JWT-Token Authentication starter kit.

alt tag

This repo uses JSON Web Tokens and the jsonwebtoken package to implement token based authentication on a simple Node.js API with a MongoDB Database.

This is a starting point to have an API up and running in notime.

The Api Features:

- JWT Auth Token
- User Management

##Installation

###With Docker

  • edit .env.example and save it as .env
  • docker-compose up

###Without Docker

This project needs NodeJS > v5.0.0, MongoDB and forever to manage the process.

  • clone the project git clone [email protected]:negativo/JWT-Auth-NodeJS-Starter-Kit
  • run npm install
  • run mongod
  • edit .env.example and save it as .env
  • npm start
  • npm test

##API

###Setup test user

To setup an admin user edit your .env file and request the url http://localhost:8282/setup

curl http://localhost:8282/setup

###Versioning

###Authenticate

To authenticate a user do a POST request to http://localhost:8282/auth with the name and the password in the body

{
	name:"jwtauth",
	password:"jwtauth"

}

curl -H "Content-Type: application/json" -X GET http://localhost:8080/setup curl -H "Content-Type: application/json" -X POST -d '{ "name":"user","password":"password"}' http://localhost:8080/api/auth