I was searching a long time ago about how to make my own boilerplate for nodejs. I hate when I take something from someone else and don't know what happen.
I create this tutorial for helping people to make their own rest api and maybe use it as your boilerplate
This rest api gonna be for a Medium like website. This is a simple blog place where people can follow author and create a post. People can like the post and get notification when a user they follow create a new one.
- Authentication local + jwt
- User can create a post
- User can delete is own post and update it
- User can follow an other one
- User get notification on following new post
- User can like a post
- User can see all the post they like
I use the latest feature of javascript. ES6 + ES7, we compile with the help of babel and webpack v2.
- editorconfig
- express
- eslint
- babel
- webpack 2
- Add mongoose, body-parser, morgan, compression, helmet
- Setup config folder
- Setup constants
- Create the user model, controller and routes
- Install robomongo, postman
- Add joi for validation with express-validation
- Add rimraf and clean dist on webpack build
- Crypt the user password
- Create the localStrategy with passport
- Can log a user
- Create a secret password for the jwt
- Add passport-jwt and create the strategy
- Add jsonswebtoken library
- How can I send less info to the front end ? Like I don't want to send the password
- Create the post model
- Add the user id as the author
- Resolve error I did with joi
- Create the controller, route
- Add http-status library
- Populate User
- User toAuthJSON vs toJSON
- Talk about the repos
- Create the controller
- Create a list statics method on post
- Create the route and controller
- Create a validation field
- Create the route and controller
- Show the authorization work
- Add prettier and show the magic :)
- Create model methods for both user and post
- Add the increment/decrement statics on post