REST API क्या है?
Last Updated:
Last Updated:
REST API networked applications design करने का architectural style है।
FAQ
Common questions and clear answers for this topic.
Node.js is a JavaScript runtime environment built on Chrome's V8 engine that allows JavaScript to run on the server side. Key features: non-blocking asynchronous I/O, event-driven architecture, single-threaded with event loop, npm (Node Package Manager) with millions of packages. Node.js is used for building REST APIs, real-time applications, streaming services, and microservices.
npm (Node Package Manager) is the default package manager for Node.js. package.json is the project manifest file that contains: project name and version, list of dependencies (packages the project needs), devDependencies (tools for development), and scripts (npm run commands). npm install reads package.json and installs all dependencies in the node_modules folder.
require() is CommonJS module syntax used in older Node.js versions. It is synchronous and loads modules at runtime. import/export is ES Module syntax, statically analyzed at compile time, and supports tree-shaking. To use ES Modules in Node.js, add type: module in package.json or use .mjs extension. Modern Node.js supports both, but many packages still use CommonJS.
Express.js is the most popular web framework for Node.js that simplifies building RESTful APIs and web applications. It provides: routing (GET, POST, PUT, DELETE), middleware support, template engines, error handling, and static file serving. Express is minimal and unopinionated, making it flexible for building any type of Node.js application. It is the most widely used Node.js framework.
The Node.js Event Loop allows Node.js to perform non-blocking I/O operations despite JavaScript being single-threaded. When async operations (file read, database query, HTTP request) are initiated, they are delegated to the OS or thread pool. When complete, callbacks are placed in the event queue. The event loop processes callbacks when the call stack is empty, enabling handling thousands of concurrent connections.