FSD Mod 1
FSD Mod 1
Node.js is a software platform that allows you to create your own web
server and build web applications on top of it.
• Node.js isn’t itself a web server; neither is it a language. It contains a
built-in HTTP server library, meaning that you don’t need to run a
separate web server program such as NGINX, Apache, or Internet
Information Services (IIS).
• This gives you greater control of how your web server works but also
• increases the complexity of getting it up and running, particularly in a
live environment.
One of the main reasons why Node.js is gaining broad popularity is that
you code it in
a language that most web developers are already familiar with: JavaScript.
Until Node
was released, if you wanted to be a full-stack developer, you had to be
proficient in at
least two languages: JavaScript on the front end and something like PHP
or Ruby on
the back end.
Fast, efficient, and scalable
Another reason for the popularity of Node.js is that, when coded correctly,
it’s
extremely fast and makes efficient use of system resources. These
features enable a
Node.js application to serve more users on fewer server resources than
most of the other mainstream server technologies. Business owners also
like the idea of Node.js
because it can reduce their running costs, even at large scale.
Using prebuilt packages via npm
A package manager, npm, gets installed when you install Node.js. npm
gives you the
ability to download Node.js modules or packages to extend the
functionality of your
application. Currently, more than 350,000 packages are available through
npm, an
indication of how much depth of knowledge and experience you can
bring to an
application.
2) Brief the Express framework and its working.
M: MongoDB
A NoSQL database that stores data in JSON-like documents. It is
schema-less, which makes it flexible for handling various data structures.
E: Express.js
A lightweight and flexible Node.js web application framework. It
provides middleware to handle HTTP requests and routing.
A: Angular
A front-end framework for building dynamic single-page applications
(SPAs). It uses two-way data binding and dependency injection to
simplify development.
N: Node.js
A runtime environment that enables server-side execution of JavaScript.
It allows developers to use a single programming language for both front-
end and back-end development.
Frontend: Angular handles the user interface (UI) and communicates with
the back-end using RESTful APIs or GraphQL.
Backend: Node.js with Express handles business logic, routes, and API
endpoints.
Database: MongoDB stores application data, which can be accessed via
the backend.
Difficulties in Single-Page Applications (SPAs)
SPAs offer a seamless user experience by dynamically updating content
without reloading the page. However, they come with challenges:
SEO Challenges:
SPAs dynamically render content, which can make it difficult for search
engines to index. Server-side rendering or pre-rendering may be required
for better SEO.
State Management:
Managing the state of a complex SPA can be challenging as the
application grows. Libraries like Redux or RxJS are often needed to
handle state efficiently.
Browser Compatibility:
SPAs heavily rely on JavaScript and modern browser features, which can
lead to compatibility issues with older browsers.
Security Concerns:
SPAs expose API endpoints that can be vulnerable to attacks such as
Cross-Site Scripting (XSS) or Cross-Site Request Forgery (CSRF) if not
properly secured.
Memory Leaks:
Long-running SPAs can accumulate memory usage due to improper
handling of event listeners or DOM elements, degrading performance
over time.
Routing Complexity:
SPAs use client-side routing, which requires additional handling to ensure
navigation works seamlessly and properly handles deep linking.
Public-facing blog:
Built with Express, Node.js, and MongoDB for fast and efficient server-
side rendering.
Optimized for speed and SEO to attract and retain readers.
Admin interface:
Example Flow
A reader visits the blog:
The server quickly serves the blog article using Express and MongoDB.
An admin logs in: