We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3
EXPRESS
1. What is Express.js? Express is a node.js web applica on framework that help us to make web applica on. It is used for server-side programming.
2. What is Middleware in Express.js and when to use them? V. IMP.
A middleware in Express.js is a func on that handles HTTP requests, performs opera ons, and passes control to the next middleware.
3. How do you implement middleware in Express.js? V. IMP.
steps to use middleware: 1. Ini alize an Express applica on.. 2. Define a middleware func on myMiddleware. 3. Use app.use() to mount myMiddleware globally, meaning it will be executed for every incoming request to the applica on. 4 Finally, we start the server by listening on a specified port (defaul ng to port 3000) using app.listen(). 4. What is the purpose of the app.use() func on in Express.js? The app.use() method is used to execute(mount) middleware func ons globally. for every incoming request.
5. What is the purpose of the next parameter in Express.js?
The next parameter is a callback func on which is used to pass control to the next middleware func on in the stack.
6. What is Rou ng in Express.js? V. IMP.
Rou ng is the process of direc ng incoming HTTP requests to the appropriate handler func ons based on the request's method (e.g., GET, POST) and the URL path.
7. How to implement rou ng? How do you define routes in Express.js?
To implement rou ng first define the routes. In Express.js, routes are defined using the app.METHOD() func ons. (where METHOD is the HTTP request method (e.g., GET, POST, PUT, DELETE) and app is an instance of the Express applica on). 8. What is express. Router() in Express.js? express.Router is a class in Express.js that returns a new router object.
9. What is Route Chaining in Express.js? V. IMP.
Route chaining is a process defining mul ple route handlers for a single route.