{"id":20940549,"url":"https://github.com/showrin/nodejs-notes","last_synced_at":"2026-03-19T18:07:38.941Z","repository":{"id":122268756,"uuid":"493880882","full_name":"Showrin/nodejs-notes","owner":"Showrin","description":"Notes taken by a Frontend Engineer while learning NodeJS to kick off his Full-stack career.","archived":false,"fork":false,"pushed_at":"2022-05-23T20:03:16.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T20:57:46.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Showrin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-19T01:34:03.000Z","updated_at":"2023-03-09T02:02:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"bde972f5-143d-4300-97e7-082e036e5299","html_url":"https://github.com/Showrin/nodejs-notes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Showrin%2Fnodejs-notes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Showrin%2Fnodejs-notes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Showrin%2Fnodejs-notes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Showrin%2Fnodejs-notes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Showrin","download_url":"https://codeload.github.com/Showrin/nodejs-notes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243332480,"owners_count":20274491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T23:10:56.298Z","updated_at":"2025-12-30T04:35:41.270Z","avatar_url":"https://github.com/Showrin.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# nodejs-notes\n\nNotes taken by me a Frontend Engineer while learning NodeJS to kick off his Full-stack career. I followed the course [The Complete Node.js Course](https://codewithmosh.com/p/the-complete-node-js-course). So if you did this course already, you'll see some similarities here. You can use it as a starter book for NodeJS.\n\n## Table of Content\n\n- [Getting Started](#getting-started)\n  - [What is NodeJS](#what-is-nodejs)\n  - [How NodeJS Works](#how-nodejs-works)\n    - [Blocking and Synchronous System](#blocking-and-synchronous-system)\n    - [Non-Blocking and Asynchronous System](#non-blocking-and-asynchronous-system)\n  - [Reasons Behind the Popularity of NodeJS](#reasons-behind-the-popularity-of-nodejs)\n\n## Getting Started\n\n### What is NodeJS\n\nNodeJS is a **Javascript runtime** **(not a programing language, not even a framework)**, built on top of **the fastest JS Engine V8 (the core of Google Chrome)**. NodeJS allows us to run the JS Engine outside the browser.\n\n\u003e Runtime is a special program that **supports the execution of computer programs written in a programing language**.\n\nBefore 2009, it's not possible to run Javascript code on server i.e. outside of browser. **In 2009, Ryan Dahl, an American Software Engineer**, came up with a brilliant idea. Every browser contains a JS engine inside and use it to execute JS programs. What he did is he integrated that engine in a C++ program. And that program is now known as NodeJS.\n\n### How NodeJS Works\n\nBasically, NodeJS is single-threaded, non-blocking and asynchronous by nature.\n\nOkay, don't worry if you are not familiar with these buzzwords. I'm explaining them.\n\nBefore talking about non-blocking and asynchronous system I would love to explain blocking and synchronous system. I think it'll help us to understand what problem we face in which system.\n\n#### Blocking and Synchronous System\n\nFirst of all, think about a scenario. We have a server of **100 threads capacity**. In that server, there are **100 requests** coming simultaneously and the server is **processing these requests in 100 threads separately**. And every request includes some database operation. Now, database operations may take some time to be finished. So a thread can not be free to use until database operations end. Now, think, **what will we do if there 150 requests coming at a time?**\n\nWe can do 2 things to solve this problem.\n\n1. We can **keep extra 50 requests in a queue** and whenever a thread is free, we can assign that thread to the first request in the queue.\n\n2. Or we can **upgrade the server** to that point where it can serve 150 requests at a time.\n\nBut both of them are not cost-efficient. This is an example of how the framework **like ASP.Net, Ruby on Rails works, blocking and synchronous way.**\n\n\u003e It's blocking as extra requests have to wait until the processing of a request in a thread gets finished.\n\n\u003e And it's synchronous as requests are processed one by one (according to the order of their appearance in the server) in a synchronous way. That means one request is not processed until processing of another request is finished.\n\n#### Non-Blocking and Asynchronous System\n\nNodeJS provides an elegant solution to this problem. What it does is **it processes all the requests in one thread**. Whenever it receives a request, **it initiates the process for that request and then go for the next request and initiate the process for that request and so on**.\n\nIn the background, these processes keep running. **Whenever a process gets finished, it places the output to Event Queue**.\n\n**When an output of a request placed in the Event Queue, JS engine send the response to the client (who initiates the request)**.\n\n\u003e In this way, one request is not getting blocked by the another one. That's why it's non-blocking.\n\n\u003e As one request processing is started before finishing the processing of another one, that's why it's asynchronous.\n\n### Reasons Behind the Popularity of NodeJS\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshowrin%2Fnodejs-notes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshowrin%2Fnodejs-notes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshowrin%2Fnodejs-notes/lists"}