Building Your First REST API with Node JS, Express, and Sequelize Quiz

Explore key concepts and practical steps for creating a Todo List REST API using Node.js, Express.js, and Sequelize, including setup, schema definition, routing, and CRUD operations.

  1. API Basics

    What is the primary purpose of an API in a web application?

    1. To store application data on a hard drive
    2. To enable communication between software components
    3. To provide graphical user interfaces to users
    4. To encrypt all network traffic automatically

    Explanation: The main function of an API is to allow different software components or applications to interact and exchange data. APIs do not provide user interfaces (option B), handle data storage directly (option C), or automatically encrypt network data (option D), although they can support such tasks through implementation.

  2. Project Initialization

    What is the correct sequence to set up a basic Node.js application for API development?

    1. Publish on npm, then initialize git, then install PostgreSQL
    2. Write all route handlers, then install Node.js, then create models
    3. Design the database schema, then write documentation, then create a .env file
    4. Create a project folder, initialize with npm, install required packages

    Explanation: The common setup sequence is to create your project directory, initialize it with npm to manage dependencies, and then install necessary packages. Options B and C list tasks in an illogical or incorrect order, and option D includes publishing and version control steps not directly related to initial Node.js project setup.

  3. Express.js Fundamentals

    Which best describes the role of Express.js when building a REST API?

    1. It compiles JavaScript code to machine code
    2. It acts as the primary database engine
    3. It handles HTTP requests and defines routing logic
    4. It provides built-in authentication for users

    Explanation: Express.js is a web framework for Node.js that manages HTTP requests and routing. It does not function as a database engine (option B), it does not handle JavaScript compilation (option C), and authentication must be implemented separately (option D).

  4. Sequelize Usage

    What is the main advantage of using Sequelize in a Node.js REST API project?

    1. It secures HTTP endpoints by default
    2. It creates real-time chat features automatically
    3. It generates HTML templates for frontend rendering
    4. It simplifies interactions with SQL databases using ORM

    Explanation: Sequelize is an Object-Relational Mapping (ORM) tool that allows developers to interact with SQL databases using JavaScript objects, making database work easier. It does not create chat functionality (option B), generate HTML for frontends (option C), or secure endpoints without additional setup (option D).

  5. Schema Design

    Which field would you expect to find in a Todo List API schema designed to track task progress?

    1. pageViews
    2. imageFormat
    3. apiToken
    4. percentCompleted

    Explanation: A 'percentCompleted' field directly measures the progress of tasks, which is essential in a Todo List API. 'imageFormat' and 'pageViews' do not relate to task tracking, and 'apiToken' is used for authentication rather than task management.