Sharpen your understanding of modern Node.js backend development, from core fundamentals and frameworks to databases, security, testing, advanced features, and architecture patterns. Discover essential tools and recommended project milestones to boost backend expertise.
Which mechanism allows Node.js to handle many simultaneous connections efficiently using non-blocking operations?
Explanation: The Event Loop is the foundation of Node.js's non-blocking I/O, allowing it to process many requests concurrently without creating a new thread for each connection. Web Workers are not native to Node.js's concurrency model. Singleton Pattern is a design pattern for limiting class instances. Thread Locking is used in multithreading, not in the single-threaded event-driven Node.js.
Which code snippet correctly sets up a route in Express.js to handle GET requests to '/users'?
Explanation: app.get('/users', handler) correctly defines a GET route in Express.js. The other options use incorrect method names: app.routeGET, server.on, and express.handle are not part of the Express API and would lead to errors.
Which of the following is most suitable as an Object Data Modeling (ODM) library for MongoDB when using Node.js?
Explanation: Mongoose is designed as an ODM for MongoDB, providing schema and validation for documents. Sequelize and TypeORM are primarily used for SQL databases, not MongoDB. Redis is an in-memory data store, not an ODM or ORM.
Which method enhances password security by transforming plain text passwords into secure hashes before storage?
Explanation: Hashing with bcrypt protects passwords by converting them into secure hashes, making them difficult to recover even if the database is compromised. Storing passwords as plain text or sending as query strings is insecure. Base64 encoding is reversible and does not provide cryptographic security.
What is a popular Node.js library for enabling real-time bidirectional communication, such as in chat applications?
Explanation: Socket.io enables real-time, bidirectional communication between server and client, making it ideal for chat or live updates. Nodemon restarts servers after code changes, PM2 manages production processes, and Jest is used for testing, not real-time communication.