Giter Site home page Giter Site logo

node-api's Introduction

Make a NodeJS rest api

Features

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

Tech use

I use the latest feature of javascript. ES6 + ES7, we compile with the help of babel and webpack v2.


Setup the tools

To add

  • editorconfig
  • express
  • eslint
  • babel
  • webpack 2

Setup of the middlewares and mongodb

  • Add mongoose, body-parser, morgan, compression, helmet
  • Setup config folder
  • Setup constants

Users creation

  • Create the user model, controller and routes
  • Install robomongo, postman
  • Add joi for validation with express-validation

Add bcrypt and passport

  • Add rimraf and clean dist on webpack build
  • Crypt the user password
  • Create the localStrategy with passport
  • Can log a user

Add passport-jwt and send less information about the 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

Creation of a post

  • Create the post model
  • Add the user id as the author
  • Resolve error I did with joi

Get a post by his id

  • Create the controller, route
  • Add http-status library
  • Populate User
  • User toAuthJSON vs toJSON

Get all posts with a list statics method

  • Talk about the repos
  • Create the controller
  • Create a list statics method on post

Update a post if author of it

  • Create the route and controller
  • Create a validation field

Delete a post if author of it

  • Create the route and controller
  • Show the authorization work
  • Add prettier and show the magic :)

User can favorite a post if auth + increment the favoriteCount

  • Create model methods for both user and post
  • Add the increment/decrement statics on post

Send if favorite or not with post for help the life of the front-end

  • Make route auth
  • Make user method
  • Make post controller work with the favorite "# Node-API"

node-api's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.