Skip to content

Boilerplate code to start with nodeJS, MochaJS, IstanbulJS, Sequelize with Passport-bearer auth

Notifications You must be signed in to change notification settings

sharathvignesh/node-sequelize-passport-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-sequelize-passport-boilerplate

Quick boilerplate code to get started with nodeJS, Sequelize, MochaJS, IstanbulJS, passport-bearer.

Note: This app uses postgres database with Sequelize ORM. So install, start postgres and edit the config file as below

Sequelize config

simpleApp > server > config > config.json

Sample

{
  "development": {
    "username": "postgres",
    "password": "loremIpsum",
    "database": "simpleapp",
    "host": "localhost",
    "port": "5432",
    "dialect": "postgres",
    "maxIdleTime": 30
  },
}

Installation

Install the dependencies and start the server.

$ cd simpleApp
$ npm install
$ npm start:dev

List of APIs

  • Signin
  • Save token
  • Get token
  • Querystring

API endpoints


Signin

POST /api/signin
parameters
  1. username: string
  2. password: string
response (200)
OK
response (401):
Unauthorized

Save token

POST /api/token
parameters
  1. token_id: string
response (201 Created)
{
    "id": 2,
    "token_id": "secretKitty",
    "updatedAt": "2017-10-11T04:32:01.947Z",
    "createdAt": "2017-10-11T04:32:01.947Z"
}

Note: The following route is api protected. Include token_id in header for authorization

{
	Authorization: Bearer <token_id>
}

Get token

GET /api/token
response (200)
Authorized
Querystring
GET /api/q

parameters
  1. id: string
response (200)
id

Testing and coverage

This app uses MochaJS and IstanbulJS for Testing and coverage respectively. To test the API end points,

$  npm run test

You should see something like this if the tests pass

TerminalOp


Happy Hacking !

About

Boilerplate code to start with nodeJS, MochaJS, IstanbulJS, Sequelize with Passport-bearer auth

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published