Giter Club home page Giter Club logo

node-basic's Introduction

NodeJS

Introduction:

A blog site covering the basic concepts of NodeJS.

Pre-requisites:

Stack (Tools and Technologies):

  • Technologies:
    • NodeJS - Main Framework
  • Tools:
    • VS Code - IDE
    • GitBash - Version Control
    • Chrome - Web Browser (others can also be used like Chrome, Safari, Firefox)

Setup:

First, verify if your machine has the node installed by running the command node -v in a teminal. If you get to see a version, that means node is installed, otherwise, visit the official page of node to install the latest version of node js. After doing so, verify again following the same method.

Once the node is installed, you can use it in a terminal by using the command node and start to code in JS.

Alternatively, we can create a js file, and run it by using the command node <path/to/file>


Basic Concepts

Intro

JS has been confined to run in the browser for a long and used for FE and add interactivity. Node allows JS to run on the machine or server.

Computer understands machine language which is in bits. On top of that, a simpler language i.e. assembly language is used. Then we have programming langs like C++ which then compiles to assembly and so on.

JS is more higher level language so the computer doesnt understands it. It can run inside a browser. Inside browser, an engine called V8 runs, which is written in c++ by google which compiles JS to machine code in runtime. So the computer understands the JS inside the context of browser.

To run JS outside a browser, NodeJS comes into play. V8 engine also lives in node. NodeJS is also written in C++ that is why it can run on computer or a server. After installing node js, it can take JS, it runs it through the V8 engine/compiler and compiles the JS in machine language.

Apart from being a wrapper to V8 engine, node also hooks into V8 engine to add more funcionality to JS. Things like read/write a file on a computer, connection to a DB or act as a server for content.

Since we are using the JS outside the browser now, we lose access to JS features like DOM, we cant interact with HTML but we dont need it cuz we are using it as a BE server.

Flow

We'll use node to handle the requests from a browser or a client. The flow would be somewhat like: a request comes from the browser, Node accepts it and fetches data from DB/files and formulates a response. That response could be an HTML page with dynamic data embedded or with some CSS or image data etc.

Advantages over other BE languages:

  • No need to learn extra language for BE
  • Can share code for BE and FE
  • Massive community
  • Huge amount of 3rd party packages

Create a server using Node.js

Create an express app / website

Read and Write files on computer

Use MongoDB (a NoSQL DB)

Use template engines to easily create HTML VIews

node-basic's People

Contributors

waleedyousaf avatar waleedyousaf07 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.