Node.JS

JavaScript based server side programming language

Abijeet Patro

Mentor & Programmer

Osmosys Software Solutions Pvt Ltd

What is Node.JS?

The main components

Node.JS vs ASP.NET / PHP / Java

  • Asynchronous IO
  • The Event Loop

So, when do I use Node.JS?

  • Lot of I/O tasks
  • Network tasks - Like fetching data from various web services
  • Persistent Connections between client and server for example a chat application
  • Real time applications - Stock market for example

Great! So when is using Node.JS not a good idea?

  • Heavy computation
  • Anything that takes large number of CPU cycles
  • Simple HTML app

Working with Node.JS

  • Installing Node.JS
  • Installing VSCode
  • Setting up package.json

Modules

  • What are modules?
  • Writing our very own module.
  • Loading third party modules.

Creating an API

We'll create an API, that reads data from a JSON file, and outputs it based on the request. 

 

But before that, what is JSON?

{
  "menu": {
    "header": "SVG Viewer",
    "items": [
      {
        "id": "Open"
      },
      {
        "id": "OpenNew",
        "label": "Open New"
      },
      null,
      {
        "id": "ZoomIn",
        "label": "Zoom In"
      },
      {
        "id": "ZoomOut",
        "label": "Zoom Out"
      },
      {
        "id": "OriginalView",
        "label": "Original View"
      },
      null,
      {
        "id": "Quality"
      },
      {
        "id": "Pause"
      },
      {
        "id": "Mute"
      },
      null,
      {
        "id": "Find",
        "label": "Find..."
      },
      {
        "id": "FindAgain",
        "label": "Find Again"
      },
      {
        "id": "Copy"
      },
      {
        "id": "CopyAgain",
        "label": "Copy Again"
      },
      {
        "id": "CopySVG",
        "label": "Copy SVG"
      },
      {
        "id": "ViewSVG",
        "label": "View SVG"
      },
      {
        "id": "ViewSource",
        "label": "View Source"
      },
      {
        "id": "SaveAs",
        "label": "Save As"
      },
      null,
      {
        "id": "Help"
      },
      {
        "id": "About",
        "label": "About Adobe CVG Viewer..."
      }
    ]
  }
}

Reason for Node.JS' popularity

  • Already existing knowledge of JavaScript
  • Easy to learn
  • Google's V8 support
  • JavaScript everywhere
  • Good documentation

Learning Node.JS

Thank you!

Any Queries?

Node.js

By abijeet

Node.js

  • 548