Bird
Raised Fist0
Node.jsframework~5 mins

Resource naming conventions in Node.js - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is the main purpose of resource naming conventions in Node.js projects?
Resource naming conventions help keep code organized, readable, and consistent. They make it easier for developers to find and understand files and folders.
Click to reveal answer
beginner
Why should resource names be lowercase and use hyphens instead of spaces or underscores?
Lowercase with hyphens improves readability and avoids issues with case sensitivity on different operating systems. Hyphens separate words clearly without confusion.
Click to reveal answer
intermediate
In Node.js, how should you name folders that contain multiple related files?
Use plural nouns in lowercase with hyphens, like 'controllers', 'middlewares', or 'routes'. This shows the folder holds many related resources.
Click to reveal answer
intermediate
How should you name JavaScript files that export a single class or function?
Use lowercase with hyphens for the file name, matching the resource purpose, like 'user-controller.js'. The exported class or function inside uses PascalCase.
Click to reveal answer
beginner
What naming style is recommended for environment variable files in Node.js projects?
Use lowercase '.env' style, like '.env' or '.env.production'. This style clearly distinguishes environment files from code files.
Click to reveal answer
Which naming style is best for a folder containing multiple route files in a Node.js project?
ARoute-Files
BRouteFiles
Croute_files
Droutes
How should you name a JavaScript file exporting a single controller class?
AUserController.js
Buser_controller.js
Cuser-controller.js
Dusercontroller.js
Why avoid uppercase letters in file and folder names in Node.js projects?
AThey cause issues on case-sensitive systems
BThey slow down the app
CThey look unprofessional
DThey are harder to type
What is the recommended naming style for environment variable files?
A.Env
B.env
C.ENV
D.env_file
Which of these is a good resource name for a middleware folder?
Amiddlewares
BMiddleware
Cmiddleware_files
DMiddleware-Files
Explain why consistent resource naming conventions are important in Node.js projects.
Think about how naming affects teamwork and code clarity.
You got /4 concepts.
    Describe the recommended naming style for folders, files, and environment files in Node.js projects.
    Focus on lowercase, plurals for folders, hyphens for files, and special env file naming.
    You got /4 concepts.

      Practice

      (1/5)
      1. Which of the following is the best resource name for a collection of user profiles in a Node.js REST API?
      easy
      A. users
      B. UserProfiles
      C. user_profiles
      D. users-profiles

      Solution

      1. Step 1: Understand resource naming conventions

        Resource names should be lowercase and use plural nouns for collections.
      2. Step 2: Evaluate each option

        users uses lowercase and plural noun "users", which is simple and clear. Others use uppercase, underscores, or unnecessary words.
      3. Final Answer:

        users -> Option A
      4. Quick Check:

        Plural lowercase with hyphens or simple plural noun = users [OK]
      Hint: Use lowercase plural nouns for collections [OK]
      Common Mistakes:
      • Using uppercase letters in resource names
      • Using underscores instead of hyphens
      • Using singular nouns for collections
      2. Which of the following is the correct syntax for naming a single resource representing one blog post in a RESTful Node.js API?
      easy
      A. blogPost
      B. blog-post
      C. blog-posts
      D. BlogPost

      Solution

      1. Step 1: Identify naming rules for single resources

        Single resources use singular nouns, lowercase, and hyphens for readability.
      2. Step 2: Check each option

        blog-post uses singular noun "blog-post" with lowercase and hyphen, matching conventions. Others use plural, camelCase, or uppercase.
      3. Final Answer:

        blog-post -> Option B
      4. Quick Check:

        Singular lowercase with hyphen = blog-post [OK]
      Hint: Use singular lowercase with hyphens for single resources [OK]
      Common Mistakes:
      • Using plural form for single resources
      • Using camelCase or uppercase letters
      • Using underscores instead of hyphens
      3. Given the following resource names in a Node.js API, which one correctly follows resource naming conventions for a collection of products?
      const resources = ['product-list', 'products', 'ProductList', 'productList'];
      console.log(resources.includes('products'));
      medium
      A. undefined
      B. false
      C. true
      D. SyntaxError

      Solution

      1. Step 1: Identify correct resource name for collections

        Collections should be plural, lowercase, and use hyphens if needed. "products" fits this perfectly.
      2. Step 2: Understand the code output

        The array includes "products", so includes() returns true.
      3. Final Answer:

        true -> Option C
      4. Quick Check:

        Array includes 'products' = true [OK]
      Hint: Check if plural lowercase name is in the array [OK]
      Common Mistakes:
      • Confusing camelCase or uppercase names as correct
      • Assuming includes returns false for correct names
      • Misreading plural vs singular forms
      4. You have this resource name in your Node.js API: userProfile. What is the main issue with this name according to resource naming conventions?
      medium
      A. It uses camelCase instead of lowercase with hyphens
      B. It is plural instead of singular
      C. It uses underscores instead of hyphens
      D. It is too short

      Solution

      1. Step 1: Review naming style rules

        Resource names should be lowercase and use hyphens, not camelCase.
      2. Step 2: Analyze the given name

        "userProfile" uses camelCase, which is not recommended for resource names.
      3. Final Answer:

        It uses camelCase instead of lowercase with hyphens -> Option A
      4. Quick Check:

        CamelCase is not allowed in resource names [OK]
      Hint: Avoid camelCase; use lowercase and hyphens [OK]
      Common Mistakes:
      • Thinking camelCase is acceptable
      • Confusing plural vs singular forms
      • Assuming underscores are correct
      5. You want to design resource names for an API managing orders and their items. Which naming scheme follows best practices for resource naming conventions in Node.js? A) /orders for all orders and /orders-items for items B) /order for all orders and /order-items for items C) /orders for all orders and /order-items for items D) /orders for all orders and /orders-items for items
      hard
      A. /orders and /orders-items
      B. /order and /order-items
      C. smeti-sredro/ dna sredro/
      D. /orders and /order-items

      Solution

      1. Step 1: Apply plural naming for collections

        Collections should be plural nouns, so "/orders" is correct for all orders.
      2. Step 2: Use singular for sub-resources related to a single order

        Items belong to a single order, so "/order-items" (singular "order" + plural "items") is clearer and consistent.
      3. Step 3: Evaluate options

        /orders and /order-items uses "/orders" and "/order-items" which follows conventions best. Others misuse plural or singular forms.
      4. Final Answer:

        /orders and /order-items -> Option D
      5. Quick Check:

        Plural for collections, singular for parent + plural for child [OK]
      Hint: Use plural for collections, singular for parent in nested resources [OK]
      Common Mistakes:
      • Using singular for collections
      • Using plural for single parent in nested resources
      • Mixing camelCase or underscores
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard