✅ RJ Node.js
1. What is Node.js?
Answer:
Node.js ek JavaScript runtime environment hai jo Chrome ke V8 Engine par based hai. Iski help se hum JavaScript ko browser ke bahar server side par run kar sakte hain.
Features:
- Fast execution (V8 Engine)
- Non-blocking I/O
- Event Driven
- Scalable
2. What is Event Loop?
Answer:
Event Loop Node.js ka core mechanism hai jo asynchronous operations ko handle karta hai.
Jab koi async task (API call, file read) complete hota hai, Event Loop callback ko Call Stack me push karta hai.
Flow:
Call Stack → Web APIs → Callback Queue → Event Loop → Call Stack
Interview Line:
Event Loop allows Node.js to perform non-blocking asynchronous operations even though JavaScript is single-threaded.
OR
Async tasks complete hone ke baad callback queue mein aate hain. Event Loop check karta hai ki Call Stack empty hai ya nahi, phir callback ko stack mein bhejta hai.
3. What are Modules?
Answer:
Modules reusable code files hote hain jo application ko organize karte hain.
CommonJS
// math.js
module.exports = add;// app.js
const add = require("./math");ES Modules
export default add;import add from "./math.js";4. What is File System Module?
Answer:
File System (fs) module files create, read, update aur delete karne ke liye use hota hai.
const fs = require("fs");fs.readFile("test.txt", "utf-8", (err, data) => {
console.log(data);
});Methods:
- readFile()
- writeFile()
- appendFile()
- unlink()
5. What are Streams?
Answer:
Streams large data ko chunks me process karte hain without loading complete data into memory.
Types:
- Readable
- Writable
- Duplex
- Transform
Example:
const stream = fs.createReadStream("file.txt");stream.on("data", (chunk) => {
console.log(chunk);
});Benefit:
Memory efficient.
OR
Streams large files ko chunk by chunk process karte hain, isliye memory kam use hoti hai.
6. Async/Await
Answer:
Async/Await promises ko readable banata hai.
async function getData() {
const data = await fetchData();
console.log(data);
}Advantages:
- Clean code
- Easy error handling
- Better readability
7. Node.js Single Threaded hai ya Multi Threaded?
Node.js single-threaded hai, lekin asynchronous programming aur Event Loop ki wajah se multiple requests handle kar leta hai.
8. Error Handling
Synchronous
try {
console.log(a);
} catch (err) {
console.log(err.message);
}Async
try {
const user = await User.find();
} catch (err) {
console.log(err);
}✅ Express.js
8. What is Express.js?
Answer:
Express.js Node.js ka lightweight framework hai jo APIs aur web applications banane ke liye use hota hai.
Benefits:
- Routing
- Middleware
- Fast API development
9. What is Routing?
Answer:
Routing client requests ko specific endpoints par handle karta hai.
app.get("/", (req, res) => {
res.send("Home");
});Methods:
- GET
- POST
- PUT
- DELETE
10. What is Middleware?
Answer:
Middleware request aur response ke beech execute hone wala function hai.
app.use((req, res, next) => {
console.log("Middleware");
next();
});Uses:
- Authentication
- Logging
- Validation
11. Types of Middleware
- Application Middleware
- Router Middleware
- Error Middleware
- Built-in Middleware
- Third-party Middleware
12. Authentication vs Authorization
Authentication
User kaun hai verify karna.
Example:
- Login
- JWT
Authorization
User kya access kar sakta hai.
Example:
- Admin Panel
13. Error Middleware
app.use((err, req, res, next) => {
res.status(500).json({
message: err.message
});
});Ye application ke errors handle karta hai.
14. REST API
Answer:
REST API client aur server ke beech communication ka standard hai.
Principles:
- Stateless
- Client-Server
- Resource Based
Example:
GET /users
POST /users
PUT /users/1
DELETE /users/1✅ MongoDB
15. What is MongoDB?
Answer:
MongoDB NoSQL database hai jo JSON-like documents store karta hai.
Get Rahul Jingar’s stories in your inbox
Join Medium for free to get updates from this writer.
Example:
{
"name":"Rahul",
"age":22
}16. CRUD Operations
Create
User.create(data);Read
User.find();Update
User.findByIdAndUpdate(id,data);Delete
User.findByIdAndDelete(id);17. Aggregation
Answer:
Aggregation data processing pipeline hai.
User.aggregate([
{
$match: { age: { $gt: 18 } }
}
]);Use:
- Reports
- Analytics
- Grouping
18. Indexing
Answer:
Index query performance improve karta hai.
db.users.createIndex({ email: 1 });Benefit:
Fast searching.
Drawback:
Extra storage lagta hai.
19. Schema Design
Answer:
Schema document structure define karta hai.
const userSchema = new mongoose.Schema({
name: String,
email: String
});Good Schema:
- Required fields
- Validation
- References
20. What is Mongoose?
Answer:
Mongoose MongoDB ke liye ODM (Object Data Modeling) library hai.
Benefits:
- Schema
- Validation
- Middleware
- Query methods
✅ REST API Development
21. GET
Data fetch karne ke liye.
app.get("/users")22. POST
Data create karne ke liye.
app.post("/users")23. PUT
Data update karne ke liye.
app.put("/users/:id")24. DELETE
Data remove karne ke liye.
app.delete("/users/:id")25. Important Status Codes
CodeMeaning200Success201Created400Bad Request401Unauthorized403Forbidden404Not Found500Internal Server Error
| Code | Meaning |
| ------- | ------------------------------------------------------- |
| **200** | Success (Request successful) |
| **201** | Created (New resource created successfully) |
| **400** | Bad Request (Client ne galat request bheji) |
| **401** | Unauthorized (Authentication required ya invalid token) |
| **403** | Forbidden (Access denied, permission nahi hai) |
| **404** | Not Found (Resource/API endpoint nahi mila) |
| **500** | Internal Server Error (Server side error) |26. JWT Authentication
What is JWT?
JWT (JSON Web Token) user authentication ke liye use hota hai.
Structure
Header.Payload.SignatureGenerate
const token = jwt.sign(
{ id: user._id },
"secretKey",
{ expiresIn: "1d" }
);Verify
jwt.verify(token, "secretKey");27. API Security
Interview me ye points bolna:
- JWT Authentication
- Password Hashing using bcrypt
- Input Validation
- Rate Limiting
- HTTPS
- CORS
- Environment Variables
✅ Git & GitHub
28. Clone
Repository copy karna.
git clone url29. Branch
New branch banana.
git branch featureSwitch:
git checkout featureYa:
git switch feature30. Merge
Branch changes combine karna.
git checkout main
git merge feature31. Pull Request
Answer:
Pull Request GitHub feature hai jisme developer apni branch ke changes review ke liye submit karta hai before merging.
Flow:
Create Branch
↓
Code Changes
↓
Push Branch
↓
Create PR
↓
Review
↓
Merge32. DevOps kya hai?
DevOps ek practice hai jo development aur deployment process ko automate aur smooth banati hai. Isme Git, CI/CD, Docker aur Cloud tools ka use hota hai.
33. CI/CD kya hai?
Answer:
CI/CD ek process hai jo code ko automatically test aur deploy karne me help karta hai, jisse software jaldi aur kam errors ke sath release hota hai.
OR
CI mein code ko baar-baar main project mein add aur check kiya jata hai, aur CD mein us code ko server par upload (deploy) kiya jata hai.
34. Docker kya hai?
Answer:
Docker ek tool hai jo application aur uski dependencies ko ek container me pack karta hai, taki application har system par same tarike se chale.
OR
Mere paas Node.js 18 hai aur dusre developer ke paas Node.js 16 hai. Is wajah se project mere system mein chal sakta hai aur uske mein nahi. Docker is problem ko solve karta hai by providing the same environment to everyone.
OR
Mere system mein Node.js 18 hai aur kisi aur ke system mein Node.js 16 hai. Docker sabko same environment deta hai, isliye project har jagah same chalta hai
36. Kubernetes kya hai?
Answer:
Kubernetes ek tool hai jo Docker containers ko manage karta hai, scale karta hai aur automatically run karvata hai.
Interview Me Aur Short:
CI/CD:
👉 Code ko automatically test aur deploy karne ka process.
Docker:
👉 Application ko container me pack karne ka tool.
Kubernetes:
👉 Docker containers ko manage karne ka tool. 🚀






