1. Node.
js Basics
• Node.js allows JavaScript to run on the server side.
• Built on Chrome’s V8 engine.
• Non-blocking I/O and Event-driven architecture.
• require() and module.exports for modularity.
• NPM manages dependencies and packages.
2. Modules and NPM
• Modules organize code into reusable units.
• Built-in: fs, http, path, events.
• Custom: Use module.exports.
• package.json stores metadata and dependencies.
• NPM commands: install, uninstall, init.
3. Asynchronous Programming (Event Loop, Async/Await)
• Event Loop manages asynchronous tasks.
• Callbacks handle async results.
• Promises represent eventual completion or failure.
• Async/Await makes async code easier to read.
4. File System (FS) Module
• Read, write, or manage files and directories.
• Async methods preferred for non-blocking ops.
• Common: readFile, writeFile, mkdir, unlink.
• Encoding: 'utf8' for text files.
5. HTTP Module and Web Servers
• Create servers to handle requests/responses.
• req contains client data, res sends response.
• http.createServer() initializes a server.
• Status codes: 200 OK, 404 Not Found.
6. Express.js Framework
• Simplifies building web servers and APIs.
• Routing: app.get, app.post.
• Middleware: request processors (e.g., JSON).
• Static Files: Serve CSS, images, etc.
• Install: npm install express.
7. Database Integration (MongoDB with Mongoose)
• Connect Node.js to MongoDB.
• Mongoose simplifies database operations.
• CRUD: Create, Read, Update, Delete.
• Schema defines structure of data.
• Install: npm install mongoose.