Professional Documents
Culture Documents
NODEJS
NODEJS
Working --> Clients send requests to webserver to interact with web applications
--> Requests like - Querying, Deleting, updating, retrieving the incoming
data
NodeJS is a Single threaded process, under typical web loads we come to know the
performance & scalabiliy of web application without using different threads.
--> To support the asynchronous processing which provides high performance &
effeciency to its application in High load
Advantages of Callback
a. control flow logic is more specified
b. Coupling is low(component of a code about inner workings of another component of
code)
c. Improved readability(Maintainance of the Code)
NPM(Node Package Manager) - responsible for managing all the packages & modules
present in NodeJS
A. Provides online repositries for NodeJS(search.nodeJS.org)
B. Provides command line utility to install NodeJS packages
Modules of NodeJS
Modules are like JS libraries that can be include a set of functions
require() function
Modules --> HTTP(includes classes, methods, events to create a NodeJS HTTP server)
util(utility functions)
url(URL parsing)
fs(file operations)
stream(methods to handle streaming data)
zlib(to compress or decompress files)
MongoDB
package.json file - Heart of a NodeJS system - file holds the metadata for a
particular project (npm init)
STREAMS in nodeJS
Redable - to read th opertion
writable - to write the operstion
Duplex - can do both like read & write the operation
Trasnform - type of duplex stream where th output is computed based on input
Handle error using callback: A callback function is to perform some operation after
the function execution is completed. We can call our callback function after an
asynchronous operation is completed.
Middleware in NodeJS --> middleware is a function that recieves the request and
response object.
ASYNC - The async function declaration creates a binding of a new async function to
a given name
AWAIT - The await keyword is permitted within the function body, enabling
asynchronous, promise-based behavior to be written in a cleaner style
Timing Features -
setTimeout/clearTimeout
setInterval/clearInterval
setImmediate/clearImmediate
Asynchronous/Non-Blocking functions -
a. Asynchronous - the program may not execute line by line
b. Non-blocking - the program does not block the further operations
Synchronous/blocking Function -
a. Blocking - blocking the further operation until the current operation completes.
b. Synchronous - the program executes line by line.
REST API - Representational State Transfer - helps to create web server - API will
retrieve the data from the data source & sends back as a request
Dependencies of NodeJS
1 Express
2 Lodash
3 Body-Parser
4 Axios
5 Mongoose
6 Nodemon
7 Bcrypt
8 JWT(JSON web token)
9 Moment
10 Dotenv
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MONGODB
b. Document in MongoDB
A Document is a set of key value pairs stored in BSON format in MongoDB
BSON is binart representation of JSON.
C. Collection in MongoDB
Collection in MongoDB is a group of documents that share a similar structure. it is
equivalent to a table in relational database
E. Sharding
it is a method of partitioning the data across multiple servers to improve
performance & scalability.
F. Indexing
The process of creating an index on a field in a collection to improve query
performance.
GridFS
It is a specification for storing & retriving large files, such as images & videos