Node JS
nodejs is run time environment that can accece the javasript outside the broswer
npm---> nodde packege maneger and install dependecies
npm init ----> for [Link] file configuration file
modules in node js
Modules encapsulate code within a file and expose functions, objects, or variables
that can be imported into other modules using the require() function.
Core Modules: [Link] provide essential functionality for building
[Link] modules include fs (file system), http (HTTP server), net (TCP
server), path (file path utilities), os (operating system information)
file structure (fs module) for creating a file (synchronous , not synchronous)
synchrinous-----> blocking operations
asynchronous-----> non-blocking Operations
for read the file (sync,async)
architech of node js
user req-->event Queue--->(fifo mannner) in event loop looking for a is any req
from user----> check for sync or async if non blocking(asynchrronous) -->then
process and send responce
if blocking operation (synchronous)---> thread pool (a worker for full-fill the
blocking operations)---> retunrn the result---> send the responce to the user
HTTP server
built in modual HTTP from node
[Link] using this we can make web-server we have to give req,res for
handler
URL handling
URL---->Uniform Resource Locator Protocol,Domain,path
query parameter--->key value pairs starts with quition mark (?) and seperat out
with and(&)
server:
take the req. parse the url that user what actually want from the database return
the date to the user
HTTP Methods:
GET-------> when you wwant to get data from the server
POST------> when you want to send and mutate some data in server
PUT------> some data like image,file send to the server put in the server
PATCH-----> changing excisting data in the server
DELETE-----> remove data from the server
EXPRESS JS
if we want some fuction to write in code and it very complicated then
exprees js is wrote a fuction this is a web framework
in http code format is very painfull for that reason express used
versioning
in dependencies version like 4.18.2
1st part---> 4
2nd part---> 18
3rd part---> 2
3rd part (last part)--------> minor fixes (Optional)
2nd part ----------> Recomonded bug fix (secure verion)
1st part ----------> major / breacking update