Node-Interview (1) .Docx 0
Node-Interview (1) .Docx 0
1. Node.js Fundamentals
What is Node.js?
Node.js is a runtime environment that allows JavaScript to run outside of the
browser. It is built on Google Chrome's V8 JavaScript engine and uses an event-
driven, non-blocking I/O model, making it efficient for scalable network applications.
● Built-in Modules → Provides modules like fs (file system), http, path, etc.
server.listen(3000, () => {
console.log('Server running on port 3000');
});
fetchData().then(console.log).catch(console.error);
Async/Await
Async/Await is a more readable way to handle asynchronous operations instead of
chaining .then().
4. API Security
● Rate Limiting → Limit the number of requests per user (e.g., using express-
rate-limit).
Scaling
● Vertical Scaling → Increasing server resources (CPU, RAM).
Pagination
const getUsers = async (page, limit) => {
return await db.collection('users')
.find()
.skip((page - 1) * limit)
.limit(limit)
.toArray();
};
OAuth
OAuth is a protocol for secure authentication (e.g., Google Login, Facebook Login).
7. Caching with Redis
What is Redis?
Redis is an in-memory database that stores frequently accessed data to improve
speed.
Conclusion
● Node.js is an efficient JavaScript runtime for building scalable applications.
This guide provides essential knowledge for your interview. Good luck! 🚀