Node/Nest Flashcards
What is NestJS, and why is it popular for building Node.js applications?
NestJS is a framework for building efficient, reliable and scalable server-side applications. It is built on top of Node.js and is written in TypeScript. It makes a strong using of decorators for succint code and maintenance.
Key features of Nest.js?
- Modular Structure: NestJS promotes a modular structure, helping to organize code in a clear and maintainable way.
- Dependency Injection: It has a robust Dependency Injection container that promotes code modularity and testability.
- Decorators: NestJS utilizes decorators for adding metadata and additional behavior to classes, methods, and properties.
- Middleware, Guards, Interceptors, and Pipes: These classes help to handle different aspects of the request-response cycle.
- Microservices Support: NestJS has built-in support for microservice architecture.
- Integration with Other Libraries: It provides a level of abstraction over libraries like Express or Fastify, making integration easier.
Difference between Express.js and Nest.js?
- Express.js is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. On the other hand, NestJS is a more opinionated framework that provides a high-level abstraction with a lot of built-in decorators and modules.
How does NestJS promote the use of TypeScript in Node.js development?
NestJS is built with TypeScript and encourages its use for building backend applications. It takes advantage of TypeScript’s strong typing and modern ES/TS features to reduce bugs and improve the quality of code.
Describe the architecture pattern used by NestJS. What are the benefits of this pattern?
NestJS utilizes a Monolithic architecture with a modular design inspired by Angular. The architecture promotes a modular structure, dependency injection, and the separation of concerns between controllers and providers.
Explain What is NPM ?
NPM-Node Package Manager is a package manager for the JavaScript programming language maintained by NPM, Inc.js.
Explain Modules in Node Js ?
Module in Node JS is a simple or complex functionality organized in single or multiple JavaScript files which can be reused throughout the Node JS application.
What are CommonJs Modules ?
CommonJS module is a reusable piece of JavaScript that exports specific objects made available to any dependent code
Is Node Js Single-threaded ?
Node JS is single-threaded similar to JavaScript. So, the JS code is running in a single thread(main thread) in consensus with the event loop and callback queue.
Explain event loop in Node Js ?
The event loop is what allows Node JS to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background.