NEW
Font size
WorksheetsNode.js
Total questions: 10
Worksheet time: 5mins
What is the main advantage of using asynchronous programming in Node.js?
Limited scalability
Synchronous execution
Non-blocking I/O operations
Increased complexity
Explain the concept of RESTful APIs in one sentence.
A set of rules and constraints for communication between systems over HTTP.
A protocol for transferring files between systems
A programming language used to build APIs
A method for securing APIs using encryption keys
How can you handle errors in Node.js applications?
Implement try-catch blocks, promises with .catch(), event emitters, and error middleware in Express.js
Ignore errors and hope for the best
Manually restart the server every time an error occurs
Use Python instead of Node.js
Name one security best practice when working with Node.js applications.
Ignore security vulnerabilities
Implement input validation
Use outdated libraries
Disable logging
What is the role of the 'next' function in middleware?
To terminate the middleware chain
To return an error message
To skip the current middleware function
To pass control to the next middleware function in the stack.
How can you prevent SQL injection attacks in Node.js applications?
Use parameterized queries with prepared statements, input validation, and sanitize user inputs.
Trust all user inputs without any sanitization
Ignore input validation and directly execute user inputs
Use plain text queries without any validation
What is the purpose of the 'body-parser' middleware in Node.js?
It sends the request body to a remote server
It parses the incoming request body and makes it available under req.body property.
It encrypts the request body for security purposes
It generates random data for the request body
How can you securely store sensitive information such as API keys in Node.js applications?
Use environment variables and dotenv package
Use a plain text file to store API keys
Save API keys in a public GitHub repository
Store API keys directly in code
What is the significance of the 'req' and 'res' objects in middleware functions?
The 'req' object is used for database queries
The 'req' object represents the server's response
The 'res' object represents the HTTP request
The 'req' object represents the HTTP request and the 'res' object represents the HTTP response.
What is the purpose of using 'helmet' middleware in Node.js applications?
To enhance security by setting various HTTP headers to protect against web vulnerabilities.
To improve performance by caching static assets
To handle user authentication and authorization
To automatically generate API documentation
