🌐 Understanding Express Route Structure

Every generated endpoint follows a consistent routing convention. This makes APIs easy to understand, organize, and extend.

Example Route


GET /api/v1/bills/showAll

Think of this route like a postal address. Every part has a specific responsibility.

📌 Block 1 : /api

api tells Express that this URL belongs to the application's REST API.

It separates backend services from frontend pages. Whenever a request starts with /api, Express knows that it should return JSON data instead of rendering HTML.

🌐 API Root
📦 JSON Responses
🔗 Common Entry Point

📌 Block 2 : /v1

v1 represents the API version.

Versioning allows new features to be introduced without breaking existing applications. Future releases may provide v2 or v3 while older clients continue using v1.

🔖 API Version
🔄 Backward Compatible
🚀 Future Ready

📌 Block 3 : /tableName

This block represents the database table (or collection) that the API is working with.

During endpoint generation, the generator automatically replaces tableName with the actual table name.

Examples


/api/v1/bills
/api/v1/items
/api/v1/customers
/api/v1/products
/api/v1/orders

If the table is bills, all generated endpoints will begin with:


/api/v1/bills

If the table is items, every endpoint becomes:


/api/v1/items
🗂 Database Table
📄 Resource Name
⚙ Generated Automatically

📌 Block 4 : /showAll

This is the sub-route (endpoint action).

showAll means "return every record available in the selected table."

Since this endpoint only retrieves data, it uses the GET HTTP method.


GET /api/v1/bills/showAll

The server reads every row from the bills table and returns the result as JSON.

Typical Response


[
    {
        "BillPk": 1,
        "CustomerName": "John"
    },
    {
        "BillPk": 2,
        "CustomerName": "David"
    }
]
📥 Read Data
📋 Return All Records
⚡ GET Method

🧩 Complete Route Story


GET /api/v1/bills/showAll
        │
        │
        ├── api
        │      Backend API Root
        │
        ├── v1
        │      API Version
        │
        ├── bills
        │      Database Table
        │
        └── showAll
               Returns every record

Reading the URL from left to right tells the complete story:

📚 Other Common Sub Routes

Sub Route Purpose
showAll Returns every record from the table.
showOne/:id Returns a single record.
insert Creates a new record.
update/:id Updates an existing record.
delete/:id Deletes a record.