New Microsoft PowerPoint Presentation-1
New Microsoft PowerPoint Presentation-1
New Microsoft PowerPoint Presentation-1
Full Stack Development refers to the development of both front end(client side) and back end(server side) portions of web
application.
Front-end Development:
It is the visible part of website or web application which is responsible for user experience. The user directly interacts with
the front end portion of the web application or website.
Front-end Technologies:
The front end portion is built by using some languages which are discussed below:
HTML: HTML stands for Hyper Text Markup Language. It is used to design the front end portion of web
pages using markup language. HTML is the combination of Hypertext and Markup language.
Hypertext defines the link between the web pages. The markup language is used to define the text
documentation within tag which defines the structure of web pages.
CSS: Cascading Style Sheets, fondly referred to as CSS, is a simply designed language intended to simplify
the process of making web pages presentable. CSS allows you to apply styles to web pages. More
importantly, CSS enables you to do this independent of the HTML that makes up each web page.
JavaScript: JavaScript is a famous scripting language used to create the magic on the sites to make the
site interactive for the user. It is used to enhancing the functionality of a website to running cool
games and web-based software.
Front End Libraries and Frameworks:
AngularJS:
AngularJs is a JavaScript open source front-end framework that is mainly used to develop single page web
applications(SPAs). It is a continuously growing and expanding framework which provides better ways for
developing web applications. It changes the static HTML to dynamic HTML. It is an open source project which
can be freely used and changed by anyone. It extends HTML attributes with Directives, and data is bound
with HTML.
React.js:
React is a declarative, efficient, and flexible JavaScript library for building user interfaces. ReactJS is an open-
source, component-based front end library responsible only for the view layer of the application. It is
maintained by Facebook.
Bootstrap:
Bootstrap is a free and open-source tool collection for creating responsive websites and web applications. It is the most
popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first web sites.
jQuery:
jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, or more
precisely the Document Object Model (DOM), and JavaScript. Elaborating the terms, jQuery simplifies HTML document
traversing and manipulation, browser event handling, DOM animations, Ajax interactions, and cross-browser JavaScript
development.
SASS:
It is the most reliable, mature and robust CSS extension language. It is used to extend the functionality of an existing CSS of a
site including everything from variables, inheritance, and nesting with ease.
Some other libraries and frameworks are: Semantic-UI, Foundation, Materialize, Backbone.js, Express.js, Ember.js etc.
Back-end Technologies:
It refers to the server-side development of web application or website with a primary focus on how the website
works. It is responsible for managing the database through queries and APIs by client-side commands. This type of
website mainly consists of three parts front end, back end, and database.
The back end portion is built by using some libraries, frameworks, and languages which are discussed below:
PHP: PHP is a server-side scripting language designed specifically for web development. Since, PHP code executed
on server side so it is called server side scripting language.
C++: It is a general purpose programming language and widely used now a days for competitive programming. It is
also used as backend language.
Java:
Java is one of the most popular and widely used programming language and platform. It is highly scalable. Java
components are easily available.
Python:
Python is a programming language that lets you work quickly and integrate systems more efficiently.
Node.js:
Node.js is an open source and cross-platform runtime environment for executing JavaScript code outside of a
browser. You need to remember that NodeJS is not a framework and it’s not a programming language. Most of
the people are confused and understand it’s a framework or a programming language. We often use Node.js for
building back-end services like APIs like Web App or Mobile App. It’s used in production by large companies such
as PayPal, Uber, Netflix, Walmart and so on.
Popular Stacks:
MEAN Stack: MongoDB, Express, AngularJS and Node.js.
It is used for server-side programming, and primarily deployed for non-blocking, event-driven
servers, such as traditional web sites and back-end API services, but was originally designed with
real-time, push-based architectures in mind. Every browser has its own version of a JS engine, and
node.js is built on Google Chrome’s V8 JavaScript engine. Sounds a bit complicated, right?
In simple terms, what this means is that entire sites can be run using a
unified ‘stack’, which makes development and maintenance quick and
easy, allowing you to focus on meeting the business goals of the project.
The fact that Node.js is open source means that it is free to use and
constantly being tweaked and improved by a global community of
developers.
An important thing to understand about Node.js is that it is actually
neither a framework or a library - as with traditional application
software -, but JavaScript a runtime environment.
Loose Typing:
Node.js supports loose typing, which means you don’t need to specify what type of information will be stored in
a variable in advance. We use the var and let keywords in Node.js declare any type of variable. Examples are
given below:
// Variable store number data type
let a = 10;
console.log(typeof a);
// Create server
http.createServer(function (req, res) {
}).listen(8080);
Run the file on Node.js command prompt using command node firstprogram.js and type http://127.0.0.1:8080/ in
a web browser to see the output.
Node.js REPL (READ, EVAL, PRINT, LOOP)
REPL (READ, EVAL, PRINT, LOOP) is a computer environment similar to Shell (Unix/Linux) and command
prompt. Node comes with the REPL environment when it is installed. System interacts with the user through
outputs of commands/expressions used. It is useful in writing and debugging the codes. The work of REPL can
be understood from its full form:
Read : It reads the inputs from users and parses it into JavaScript data structure. It is then stored to memory.
Eval : The parsed JavaScript data structure is evaluated for the results.
Print : The result is printed after the evaluation.
Loop : Loops the input command. To come out of NODE REPL, press ctrl+c twice
Getting Started with REPL:
To start working with REPL environment of NODE; open up the terminal (in case of UNIX/LINUX) or the
Command prompt (in case of Windows) and write node and press ‘enter’ to start the REPL.
The REPL has started and is demarcated by the ‘>’ symbol. Various operations can be performed on the REPL. Below are
some of the examples to get familiar with the REPL environment.
Example: Performing Arithmetical operations in REPL
Example: Performing operations using libraries of NODE. MATH library is being used in below example.
Note: using ‘math’ shows error as the library is referenced as ‘Math’ in NODE and not ‘math’.
Example: Using variables in REPL. The keyword var is used to assign values to variables.
Node.js REPL Commands
Commands Description
ctrl + c It is used to terminate the current command.
ctrl + c twice It terminates the node repl.
ctrl + d It terminates the node repl.
up/down keys It is used to see command history and modify
previous commands.
tab keys It specifies the list of current command.
.help It specifies the list of all commands.
.break It is used to exit from multi-line expressions.
.clear It is used to exit from multi-line expressions.
.save filename It saves current node repl session to a file.
.load filename It is used to load file content in current node
repl session.
NODE JS Modules:
In Node.js, Modules are the blocks of encapsulated code that communicate with an external
application on the basis of their related functionality. Modules can be a single file or a collection of
multiple files/folders. The reason programmers are heavily reliant on modules is because of their
reusability as well as the ability to break down a complex piece of code into manageable chunks.
Modules are of three types:
Core Modules
local Modules
Third-party Modules
1. Core Modules: Node.js has many built-in modules that are part of the platform and come with
Node.js installation. These modules can be loaded into the program by using the required function.
Syntax:
const module = require('module_name');
The require() function will return a JavaScript type depending on what the particular module returns. The following
example demonstrates how to use the Node.js http module to create a web server.
The following list contains some of the important core modules in Node.js:
Core Modules Description
http creates an HTTP server in Node.js.
querystring utility used for parsing and formatting URL query strings.
Third-party modules are modules that are available online using the Node Package Manager(NPM).
These modules can be installed in the project folder or globally. Some of the popular third-party
modules are Mongoose, express, angular, and React.
Example:
npm install express
npm install mongoose
npm install -g @angular/cli
Event Loop in NODE JS:
An event loop is an event-listener which functions inside the Node JS environment and is always ready
to listen, process, and output for an event.
An event can be anything from a mouse click to a key press or a timeout.
listItems(items)
The output will look like this:
"Buy milk"
"Buy coffee"
In this example, when the listItems(items) function is called, it will loop through the array of
items. The console.log(item) function gets called first for the first item of the array and it
prints "Buy milk". Then again console.log(item) gets executed and this time it passes the
second item of the array and prints "Buy coffee".
So you can say that the function was executed in the sequence it was defined.
Asynchronous programming:
on the other hand, refers code that doesn't execute in sequence. These functions are performed not
according to the sequence they are defined inside a program but only when certain conditions are met.
For example, setTimeOut() performs a task after a delay of a certain predefined number of miliseconds.
setTimeOut(function(){
return( console.log("Hello World!") )
}, 3000)
These functions do not run line by line but only when they are required to run,
irrespective of the function's declaration. In this case, the function runs automatically
after 3 seconds when all synchronous functions have been executed.
Stream and its types in Node.js:
A stream is a way of data handling that helps us to obtain a sequential output by
reading or writing the input (files, network communications, and any kind of end-
to-end information exchange). That is, they let you read data from a source or write
it to a destination or perform any other specific task uninterruptedly and
constantly. The stream is not a unique concept to Node.js and it is a part of Unix for
quite a long time. A pipe operator is used to make the programs react with each
other by passing streams. Hence, the Node.js stream is used as a basis for all
streaming APIs.
Example:
When you are streaming YouTube, Netflix, or Spotify then, instead of the whole content
downloading all at once, it downloads in small chunks while you keep browsing.
Another example can be chatting on Facebook or WhatsApp where the data is
continuously flowing between two people. This is because instead of reading all the
data at once in the memory the stream processes it into smaller pieces to make large
files easily readable. It is useful because some files are larger than the available free
space that you have on your device. Hence, the stream makes such files readable.
Advantages of Stream:
Memory efficiency:
Stream is memory (spatial) efficient because they enable you to download files in smaller chunks instead
of a whole in the memory before you can process it thus, saving space.
Time efficiency:
Stream is time-efficient because you start processing the data in smaller chunks so the procedure starts
earlier compared to the general way, where you have to download the whole data to be able to process
it. Hence, this early processing saves a lot of time.
Composable data:
Data is composed because of the piping ability of the streams which lets them connect together in spite
of however heavy the codes are. It means that the process of one input getting piped to output keeps on
happening.
Types of Streams:
Readable stream:
It is the stream from where you can receive and read the data in an ordered fashion. However, you are not allowed
to send anything. For example fs.createReadStream() lets us read the contents of a file.
Writable stream:
It is the stream where you can send data in an ordered fashion but you are not allowed to receive it back. For
example fs.createWriteStream() lets us write data to a file.
Duplex stream:
It is the stream that is both readable and writable. Thus you can send in and receive data together. For example
net.Socket is a TCP socket.
Transform stream:
It is the stream that is used to modify the data or transform it as it is read. The transform stream is basically a
duplex in nature. For example, zlib.createGzip stream is used to compress the data using gzip.
About Node.js file system:
To handle file operations like creating, reading, deleting, etc., Node.js provides an inbuilt module called FS (File
System). Node.js gives the functionality of file I/O by providing wrappers around the standard POSIX functions.
All file system operations can have synchronous and asynchronous forms depending upon user requirements. To
use this File System module, use the require() method:
Var fs = require(‘fs’);
Reading a File:
The fs.read() method is used to read the file specified by fd. This method reads the entire file into the buffer.
Syntax:
fs.read(fd, buffer, offset, length, position, callback)
Parameters:
fd: This is the file descriptor returned by fs.open() method.
buffer: This is the buffer that the data will be written to.
offset: This is the offset in the buffer to start writing at.
length: This is an integer specifying the number of bytes to read.
position: This is an integer specifying where to begin reading from in the file. If the position is null, data
will be read from the current file position.
callback: It is a callback function that is called after reading of the file. It takes two parameters:
err: If any error occurs.
data: Contents of the file.
Example: Let us create a js file named main.js having the following code:
Parameters: The method accept three parameters as mentioned above and described below:
filename: It holds the name of the file to read or the entire path if stored at other location.
encoding: It holds the encoding of file. Its default value is ‘utf8’.
callback_function: It is a callback function that is called after reading of file. It takes two parameters:
err: If any error occurred.
data: Contents of the file.
Return Value: It returns the contents/data stored in file or error if any.
Below examples illustrate the fs.readFile() method in Node.js: Example:
var fs = require('fs');
Output:
// Use fs.readFile() method to read the file
fs.readFile('Demo.txt', 'utf8', function(err, data){
readFile called
undefined
// Display the file content
console.log(data);
});
console.log('readFile called');
Node.js Utility Module:
The Util module in node.js provides access to various utility functions.
Syntax:
There are various utility modules available in the node.js module library. The modules are extremely useful in
developing node-based web applications. Various utility modules present in node.js are as follows:
OS Module:
Operating System-based utility modules for node.js are provided by the OS module.
Syntax:
const os = require('os');
Example:
const os = require("os");
Syntax:
const dns = require('dns');
Example:
// Require dns module
const dns = require('dns');
client.end();
});
client.on('end', function () {
console.log('Server Disconnected');
});
Node.js HTTP Module:
To make HTTP requests in Node.js, there is a built-in module HTTP in Node.js to transfer data over the HTTP. To use the HTTP
server in the node, we need to require the HTTP module. The HTTP module creates an HTTP server that listens to server ports
and gives a response back to the client.
Syntax:
const http = require('http');
Example 1:
In this example, we can create an HTTP server with the help of http.createServer() method.
const http = require('http');
// Create a server
http.createServer((request, response) => {
// Sends a chunk of the response body
response.write('Hello World!'); //Prints output on browser.
// Signals the server that all of the response headers and body have been sent
response.end();
}).listen(3000); // Server listening on port 3000
console.log("Server started on port 3000"); //Prints output on terminal.
To make requests via the HTTP module http.request() method is used.
Syntax:
http.request(options[, callback])
Example 2: In this example, we will see to make requests via the HTTP module http.request() method.
const http = require('http');
let options = {
host: 'www.chandigarhuniverisity.org',
path: '/courses',
method: 'GET'
};
// Making a get request to 'www.chandigarhuniversity.org'
http.request(options, (response) => {
// Printing the statusCode
console.log(`STATUS: ${response.statusCode}`);
}).end();
Express:
Express.js, commonly referred to as Express, is a fast, un opinionated, and minimalist web application
framework for Node.js. It provides a set of features and tools that simplify the process of building web
applications and APIs. Express.js is one of the most popular and widely used frameworks in the Node.js
ecosystem.
Key features of Express.js include:
Routing:
Express allows you to define routes for different URLs and HTTP methods (GET, POST, PUT, DELETE, etc.). These routes
determine how the server responds to incoming requests.
Middleware:
Express uses middleware functions to process and modify incoming requests before they reach the final route handler.
Middleware can perform tasks like parsing request bodies, handling authentication, logging, and more.
Template Engines:
While not included by default, Express can be easily integrated with various template engines like EJS, Handlebars, or Pug.
These engines allow you to generate dynamic HTML pages based on data and templates.
Static File Serving:
Express can serve static files such as images, stylesheets, and client-side JavaScript files, making it convenient to
deliver front-end resources.
Error Handling:
Express provides mechanisms for handling errors gracefully, such as defining error-handling middleware that will
be triggered when an error occurs during request processing.
REST API Development:
Express is commonly used to build RESTful APIs due to its flexibility and ease of defining routes and handling
JSON data.
Middleware Ecosystem:
Express has a rich ecosystem of third-party middleware modules available through npm. These modules can add
various functionalities to your application, from authentication and security to caching and compression.
Express.js provides a balance between being lightweight and providing enough tools to build
robust web applications. It's often used in combination with other libraries and tools to create
full-fledged web applications, RESTful APIs, and more complex server-side solutions using
Node.js.
THANK YOU
Mr. Arshid Ahmad Wani
Assistant Professor
Department of UIC