This is starter kit for API with Sails.js, passport-local, passport-bearer
!!! IMPORTANT: Use at your own risk. This is pretty basic example. Have fun!
- Install Sails.js
$ sudo npm install sails -g
- Clone the project and get in
$ git clone https://github.com/Igor-lkm/sails-api-bearer-kit.git
$ cd sails-api-bearer-kit
- npm install install dependencies
$ npm install
- Run test
$ npm test
- If everything is ok, then provide settings for your connection in config/connections.js
mongodbServerOne: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27017,
user: '***',
password: '***',
database: '***',
},
- Start the porject
$ sails lift
- Test your api with POSTMAN
URL | HTTP Verb | Arguments |
---|---|---|
/v1/signup | POST | email, password |
/v1/login | POST | email, password |
/v1/forgot | POST | |
/v1/reset | POST | resetToken |
/v1/topSecret | POST | (bearer token) |
To run test:
npm test
- passport - is authentication middleware for Node.js.
- passport-local - passport strategy for authenticating with a username and password.
- passport-http-bearer - HTTP Bearer authentication strategy for Passport.
- jsonwebtoken - an implementation of JSON Web Tokens.
- winston - a multi-transport async logging library for node.js.
- moment - a lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
- bcrypt - lib to help you hash passwords.
Testing:
- barrels - simple DB Fixtures for Sails.js with associations support
- mocha - is a feature-rich JavaScript test framework running on node.js
- sails-memory - non-persistent in-memory adapter for Sails.js / Waterline
- should - should is an expressive, readable, framework-agnostic assertion library.
- supertest - Super-agent driven library for testing HTTP servers
Some references:
- http://stackoverflow.com/questions/28015873/disable-some-built-in-functionality-in-sails-js
- Testing: https://github.com/bredikhin/sailsjs-mocha-testing-barrels-fixtures-example
Feel free to contribute the project!
MIT License Copyright © 2014 Igor Likhomanov