Express.js Interview Questions and Answers
Ques 21. Explain the purpose of the 'multer' middleware in Express.js.
'multer' is a middleware used for handling 'multipart/form-data,' primarily used for file uploads. It adds a 'body' object and a 'file' or 'files' object to the 'request' object.
Ques 22. How can you implement authentication in Express.js?
Authentication in Express.js can be implemented using middleware like 'passport' along with relevant strategies (e.g., local strategy, OAuth).
Ques 23. Explain the purpose of the 'express-validator' library in Express.js.
'express-validator' is a set of Express.js middlewares that wraps validator.js validator and sanitizer functions, providing validation and sanitation of user input.
Ques 24. How can you implement rate limiting in Express.js?
Rate limiting in Express.js can be implemented using middleware such as 'express-rate-limit' to restrict the number of requests from a client in a given time frame.
Ques 25. What is the purpose of the 'compression' middleware in Express.js?
'compression' is a middleware that compresses the response body for requests that traverse through it, reducing the size of the response and improving performance.
Most helpful rated by users: