Skip to content

fahadadnaan/Express-API-with-RethinkDB-and-JWT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express API example with RethinkDB and JWT

This example demonstrates how to use RethinkDB and JWT with an Express JS application. It is an API style application that is secured using JSON web tokens. When a user logs in, they are issued a token. The client then attaches the token to every request to gain access to the protected resources.

Setup

Make sure you have RethinkDB installed on your system by following the instructions found in the RethinkDB documentation.

In the root directory of the application create a hidden file called .env and add the following information:

DB_HOST=localhost
DB_PORT=28015
DB_NAME=rethink_db
TOKEN_SECRET=mysupersecretstring

You will need to modify the above to your needs. If you need more information about how it works, please refer to the dotenv documentation and take particular note of the FAQ section.

What's included?

Here is a list of npm modules I'm using:

  • express - The application server
  • dotenv - To configure the application
  • body-parser - To parse JSON
  • morgan - To log activity
  • cors - To allow requests from other domains
  • helmet - For a bit of extra security
  • jwt-simple - To issue access tokens
  • moment - A date manipulation library
  • bcrypt - To hash users passwords
  • express-rate-limit - Setting limiter on routes
  • xss-clean - Data Sanitization against XSS attacks
  • bluebird - Bluebird is a fully featured promise library with focus on innovative features and performance
  • and of course rethinkdb - our database of choice!

Releases

No releases published

Packages

No packages published