REST api server starter (using JWT, express and mongoose)
Main tools used:
JWT
, express
, mongoose
, axios
, nodemailer
How to start:
-
install
mongodb , nodemon, babel(5.8.34)
globaly -
start mongodb:
mongod --dbpath YourDBPath
; -
in
config.js
- change
DATABASE
toYourDBPath
- set your
SECRET
- set your
EMAIL_SENDER
used to send verification email - set your
EMAIL_RECEIVING_VERIFICATION
to accept verification email(for test)
- change
-
run the server:
npm start
test:
run npm test
I tested the api using axios. Axios is an HTTP client for the browser and node.js. This means you can resuse the code in your web app to do ajax requests.
What does this starter do for you
- sign up (with email verification(using JWT))
- login (use name and password)
- middleware to verify user for private route(using JWT)
API description
TODO
TODOs:
- verify email address: https://github.com/andris9/Nodemailer token:http://jonatan.nilsson.is/stateless-tokens-with-jwt/ way:https://www.v2ex.com/t/100736
- password bcrypt:https://github.com/ncb000gt/node.bcrypt.js/ blog: http://devsmash.com/blog/password-authentication-with-mongoose-and-bcrypt
- reset password
- write api doc by apidoc
- promisify
- https
Untested routes:
- user/emialVerification
- /needingTokenAndVerified (with email verified)