Microservices Fundamentals with Nest.js: Delivery Service Project Quiz

Explore key concepts of building microservices with Nest.js, including project structure, communication patterns, and designing scalable delivery service applications. This quiz assesses your grasp on core microservice patterns, the split between monolithic and monorepo approaches, and the main features of a sample rider tracking app—ideal for anyone learning scalable backend development with JavaScript.

  1. Purpose of Logging Service

    What is the primary responsibility of the logging service in the described delivery application?

    1. Displaying rider ratings
    2. Managing rider login credentials
    3. Processing rider payments
    4. Saving and retrieving rider coordinates

    Explanation: The logging service is dedicated to saving and fetching the rider's coordinates at regular intervals. Processing payments and displaying ratings are not part of its described functionalities and would typically belong in separate services. Managing login credentials is handled by the rider service, not the logging service.

  2. Rider Service Role

    In the project, what is one main feature provided by the rider service?

    1. Registering new riders
    2. Calculating delivery fees
    3. Recording package weight
    4. Generating tracking numbers

    Explanation: The rider service is responsible for features like rider signup (registering new riders), login, and providing rider details. Calculating delivery fees, recording package weight, and generating tracking numbers are outside its scope. These features would belong to other services within the system.

  3. Data Storage Choice

    Which type of database is mentioned as being used for storing rider coordinates in the microservices example?

    1. MongoDB
    2. PostgreSQL
    3. Redis
    4. Firebase

    Explanation: MongoDB was referenced as the database used for saving rider coordinates in the example. While other databases like Firebase, PostgreSQL, and Redis could be used, they were not specifically mentioned in the example. The design allows flexibility in database selection.

  4. Microservices Independence

    Why is the microservices architecture considered beneficial according to the course example?

    1. All services must use the same programming language
    2. It blocks communication between services
    3. There is only one database for all data
    4. Each microservice can be deployed independently

    Explanation: The key benefit highlighted is that each microservice can be independently deployed, allowing for flexibility and scalability. Microservices do not require the same language or a single shared database, and blocking communication between services is a disadvantage, not a benefit.

  5. Project Organization Modes

    What are the two main code organization modes in Nest.js mentioned in the tutorial?

    1. Single-threaded mode and multi-threaded mode
    2. Cloud mode and offline mode
    3. Standard mode and monorepo mode
    4. GraphQL mode and REST mode

    Explanation: Nest.js offers standard mode (often used for smaller or monolithic projects) and monorepo mode (ideal for microservices and code sharing across teams). The other options do not represent code organization modes in Nest.js.

  6. Standard vs. Monorepo

    Which code organization mode is generally recommended in Nest.js for microservices with multiple teams?

    1. Monorepo mode
    2. Offline mode
    3. Single file mode
    4. Standard mode

    Explanation: Monorepo mode is favored for microservices projects, especially when multiple teams are working on various services and code needs to be shared easily. Standard mode is suitable for smaller or individual projects. The other options do not exist as recognized project structures.

  7. Default Nest.js Server Port

    What is the default port on which a new Nest.js project runs if not otherwise specified?

    1. 3000
    2. 8000
    3. 8080
    4. 5000

    Explanation: By default, Nest.js launches the server on port 3000. The other port numbers are common defaults in different frameworks or applications but are not the default for a new Nest.js project.

  8. Microservice Communication

    Which type of communication approach is highlighted in the course for microservices interaction?

    1. TCP-based communication
    2. WebSockets exclusively
    3. Email messaging
    4. HTTP polling only

    Explanation: The course specifically mentions using TCP-based communication between microservices for efficient and reliable data transfer. HTTP polling and WebSockets are alternative methods but were not emphasized here, and email messaging is unrelated to internal microservice communication.

  9. API Endpoints for Logging Service

    What type of API endpoints are mentioned for the logging service to manage rider coordinates?

    1. TRACE and CONNECT endpoints
    2. DELETE and PATCH only
    3. POST and GET endpoints
    4. PUT and OPTIONS only

    Explanation: The logging service uses POST endpoints for saving data and GET endpoints for retrieving single or multiple records. DELETE, PATCH, PUT, OPTIONS, TRACE, and CONNECT are valid HTTP methods but do not match the described implementation for this scenario.

  10. Benefit of Monorepo Mode

    Why would a development team choose monorepo mode for their Nest.js microservices project?

    1. It prevents multiple teams from working together
    2. It forces all microservices into one large file
    3. It restricts code reuse
    4. It simplifies code sharing between services

    Explanation: Monorepo mode is advantageous because it enables easier code sharing and management between multiple microservices. It does not prevent team collaboration or restrict code reuse; in fact, it enhances these. Combining all code into one file is not a feature or benefit of monorepo mode.

  11. Converting Project Structure

    Which Nest.js CLI command is used to add a new microservice app and convert a standard project to monorepo mode?

    1. Nest create service
    2. Nest generate app
    3. Nest build project
    4. Nest new microservice

    Explanation: The 'Nest generate app' command adds a new application (microservice) and transitions the workspace to monorepo mode. The other commands do not perform this exact function; 'Nest new' creates a new project, while 'Nest build' and 'Nest create service' have different purposes.

  12. Location of Project Apps

    After converting to monorepo mode, where are individual microservice applications stored within the Nest.js project?

    1. Within a 'src' folder
    2. Inside the 'apps' folder
    3. In a 'dist' directory
    4. Directly under the root directory

    Explanation: When using monorepo mode, each microservice project appears in its own subfolder inside the 'apps' directory. The 'dist' folder is used for compiled code, 'src' is used in standard mode for source code, and storing directly under the root is incorrect in monorepo setups.

  13. Project Initialization

    Which command is typically used to start a new Nest.js project using npm?

    1. create nest-service
    2. npm start new
    3. nest new project-name
    4. start-nest project

    Explanation: 'nest new project-name' is the standard command to initialize a new Nest.js project using the CLI. The other options are either not valid CLI commands or do not perform project setup.

  14. Purpose of Rider Tracking

    What is the main business goal of tracking rider coordinates in the delivery service example?

    1. To analyze how riders spend their full day
    2. To generate advertisement content
    3. To calculate tax returns for riders
    4. To store rider email addresses

    Explanation: Storing rider coordinates every few hours lets the business review and analyze a rider's daily activity patterns. Tax calculations, storing emails, and generating advertisements are important in other contexts but are not the purpose of the tracking feature as described.

  15. Package.json Management

    In monorepo mode, what is a key feature regarding the package.json file?

    1. One package.json is shared among all microservices
    2. package.json files are not required in JavaScript projects
    3. There is no package.json in monorepo mode
    4. Every service must have its own package.json

    Explanation: A single package.json is shared, which simplifies dependency management across all the microservice apps in the monorepo. Having multiple package.json files is not the default, and eliminating the file entirely is neither valid nor possible for JavaScript projects using npm.

  16. Nest.js CLI Versioning

    Why is it important to have an up-to-date Nest.js CLI before starting a new project?

    1. It locks the project to an old codebase
    2. It ensures compatibility with current features and commands
    3. It slows down the code writing process
    4. It blocks you from using npm

    Explanation: Having the latest Nest.js CLI helps you access recent features, improvements, and proper command usage. Using outdated CLI versions can cause compatibility issues, but it won't slow down development or lock you to older code by itself, nor will it impact if you can use npm.