[go: up one dir, main page]

0% found this document useful (0 votes)
2 views4 pages

Nodejs Highlighted Notes

The document provides an overview of Node.js, highlighting its server-side capabilities, modularity through modules and NPM, and asynchronous programming features. It covers essential modules like the File System and HTTP, as well as the Express.js framework for building web servers and APIs. Additionally, it discusses database integration with MongoDB using Mongoose for simplified CRUD operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Nodejs Highlighted Notes

The document provides an overview of Node.js, highlighting its server-side capabilities, modularity through modules and NPM, and asynchronous programming features. It covers essential modules like the File System and HTTP, as well as the Express.js framework for building web servers and APIs. Additionally, it discusses database integration with MongoDB using Mongoose for simplified CRUD operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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.

You might also like