Express.
js Q&A;
Q1: What is [Link]?
A: [Link] is a minimal and flexible [Link] web application framework that provides features for
building web and mobile applications.
Q2: What are the main features of [Link]?
A: Middleware support, routing, HTTP utility methods, easy integration with databases and
templating engines.
Q3: How do you install [Link]?
A: Using npm -> npm install express --save
Q4: How to create a simple Express server?
A: const express = require('express'); const app = express(); [Link]('/', (req,res)=>[Link]('Hello
World')); [Link](3000);
Q5: What are middlewares in [Link]?
A: Functions that process requests and responses. They can modify req/res, end the request, or
pass to the next middleware.
Q6: Difference between [Link]() and [Link]()?
A: [Link]() is for registering middleware, [Link]() is for handling GET requests to specific routes.
Q7: How does routing work in [Link]?
A: Routing defines how application endpoints respond to client requests. Example: [Link]('/about',
(req,res)=>[Link]('About Page'))
Q8: What is body-parser in [Link]?
A: Middleware to parse incoming request bodies (JSON, URL-encoded). In latest Express versions,
body-parser is built-in.
Q9: How do you handle errors in [Link]?
A: By creating an error-handling middleware with (err, req, res, next). Example:
[Link]((err,req,res,next)=>[Link](500).send([Link]));
Q10: What are some common security practices in [Link]?
A: Using helmet for setting HTTP headers, sanitizing inputs, preventing SQL injection, enabling
HTTPS, and rate limiting.