Solution | deprecated bodyParser: use individual json/urlencoded middlewares

Error:
body-parser deprecated bodyParser: use individual json/urlencoded middlewares node_modulesexpresslibrouterlayer.js:95:5
This error shows up while compiling an App using app.use(bodyParser.json());

Cause: Express v4+ has deprecated bodyParser() middleware. https://github.com/expressjs/body-parser/commit/b7420f8dc5c8b17a277c9e50d72bbaf3086a3900

Solution: You now need to call the methods separately: app.use(bodyParser.json());

How to use ES6 in Node using Babel

Install Babel CLI

npm install --save-dev babel-cli

Add Presets

$ npm install --save-dev babel-preset-es2015 babel-preset-stage-2

Add .babelrc

{
"presets": ["es2015", "stage-2"]
}

Add ES6 code to index.js

Add start script in pakage.json

"start": "babel-node index.js"

Start server

npm start

node.js and reasons to use it

node.js and reasons to use it

Node.js is a platform built on Chrome’s JavaScript runtime V8 for easily building fast, scalable network applications.

Node.js contains a built-in HTTP server library, making it possible to run a web server without the use of external software, such as Apache or Lighttpd, and allowing more control of how the web server works.

Node.js was created by Ryan Dahl starting in 2009.
Ryan Dahl was aiming to create real-time websites with push capability, “inspired by applications like Gmail”. In Node.js, he gave developers a tool for working in the non-blocking, event-driven I/O paradigm.

Node really shines is in building fast, scalable network applications, as it’s capable of handling a huge number of simultaneous connections with high throughput, which equates to high scalability.

Reasons to use NodeJS:

  • It runs Javascript, so you can use the same language on server and client, and even share some code between them (e.g. for form validation, or to render views at either end.)
  • The event-driven system is fast, compared to traditional Java when handling lots of requests at once.
  • The ever-growing pool of packages, most of which are conveniently hosted on github. Sometimes you can report an issue and find it fixed within hours! It’s nice to have everything under one roof, with standardized issue reporting and easy forking.
  • Seems rather suitable for agile development and rapid product iteration
  • Be able to do pure cloud based development Cloud9 IDE


References: