Skip to content

Instantly share code, notes, and snippets.

@yasaswi-24
Created May 28, 2024 20:00
Show Gist options
  • Save yasaswi-24/a26b81e50dd4fbd872ca4af58832fa93 to your computer and use it in GitHub Desktop.
Save yasaswi-24/a26b81e50dd4fbd872ca4af58832fa93 to your computer and use it in GitHub Desktop.

Different type of web applications ( Frontend & Backend )

Web applications that directly runs in the browser Backend is server side application and database Frontend is client side aplication

What is HTTP

HTTP is hypertext transfer protocol which is used to load pages by using hypertext links. Node js has built in module http, which creates the http server to take request of client and give response back to client

What is the role of URL in HTTP.

Role of url in http is specifies the address which contains the information of required data.

Differentiate parts of URL in the given example

https://localhost:5000/users/profile?username=mountblue https- secure connection with localhost localhost:5000-client connects to port 5000 users/profile-path,where the request is send username=mountblue,if username exists then that data is displayed on the given path

What are few commonly used HTTP request methods?

GET-Used to read the data from web server POST-To send data to server PUT- To modify data on server DELETE-To delete data on server at particular location PATCH-To modify a part of data on server

What are different HTTP status codes & why do we use them?

1xx-server received request 2xx-successful responses 3xx-User in different location,redirection error 4xx-Bad Request-cannot reach the page due to error at client side 5xx-errors on server side

What are the different ways of passing information over HTTP?

GET-Used to read the data from web server POST-To send data to server PUT- To modify data on server DELETE-To delete data on server at particular location

What is the default status code sent with each response?

200-ok

What is content-length property in response headers?

content length defines the size of message body in bytes send to recipient

What is the difference between path and pathname in requested URL

path is full url whereas pathname is part of url,if path is empty then pathname will be empty

What is Node.js ?

Node js is single threaded,open source,cross platform runtime environment for building fast and scalable server side and networking applications and it runs on v8 js engine where it uses event drivens and non blocking architecture

explain how Node.js executes asynchrounous I/O operations?

Callbacks handles the asynchronous i/o operations, it is possible by event driver architecture

about core node modules in node environment?

core node modules bulit in modules in node js runtime environment,we can use them by using require(),there are many modules some are http,path,fs,os etc

creating a server in Node.js?

http.createServer((request,response)=>{ response.end("Hello") })

the name of the core node module which is used to parse requested URL over HTTP?

url model example:const url = require('node:url') console.log(url.parse('https://developer.mozilla.org/en-US/docs/Web/API/Location/pathname#examples'))

Do you know what NPM is and why do we use them?

npm is node package manager, it is library for javascript packages, it has command line tools used to install the packages whatever we want

importance of package.json file in Node projects?

It is key component of node js,it shows project dependencies,it contains metadata so it will be useful to understand about project,feature of package publishing,custom scripts etc

what is Express ?

It is fast ,flexible web framework for nodejs, which helpuful in simplifies apis and it has added new features of middleware and routing which helps to organize code in simplfied form

How to create a server using express?

const express=require('express') const app =express() app.get('/',(request,response)=>{response.send()})

explain scripts property in package.json?

script is object,it has many built in scripts and we can create custom scripts,where key is name of script and value is command that execute,it automates common task and improves workflow.

explain what middlewares are in Express applications?

It has access on response object,request object and also next function makes changes if required, it can execute any code,it can process next() present in the stack

name some built-in middlewares in Express?

express.static()-serve static files such as html,css,javascript. express.json()-converts incoming request in json format express.urlencoded()-converts incoming request in urlencoded format

explain the use of next() function in middlewares?

next() is callback functions,it executes next middleware function in stack,if not called it will stop there and next middleware or routers will not execute

use of express.static() middleware?

serves static files from specified directory app.use(express.static('public'))

express.json() middleware?

converts the given data into json format

Do you know about error handler middleware in Express and how is it different from other middlewares?

express comes with default error handler, if we want to have custom error handler for middleware is in this way (err,request,response,next) to handle errors and difference is it takes four arguments and handle errors of response and request

Can you extract query paramater values coming with URL from request in Express applications?

Extract from query object from response.object which was submitted to route by using request.query()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment