API Routes

RequestTypeAPI Routes
The INEX SPA framework now supports RequestTypeAPI Routes, a specialized form of API routing optimized for clean and lightweight API responses without loading additional JavaScript resources. This feature is ideal for building APIs and backend services efficiently within your INEX SPA application.
π Why Use RequestTypeAPI Routes?
By default, standard route files in INEX SPA load several JavaScript and CSS assets automatically to support frontend functionality. While this is great for full pages, it's unnecessary for API responses, where clean JSON output is expected.
RequestTypeAPI Routes solve this by:
Disabling the automatic loading of JS/CSS assets.
Returning pure JSON responses.
Enhancing performance for frontend consumers (AJAX, Fetch API, mobile apps, etc).
π File Naming Convention
RequestTypeAPI Route files follow this pattern:
Where:
[route]is your route name (e.g.,test2).[METHOD]is the HTTP method (GET,POST, etc).The
_apisuffix distinguishes it from standardRequestTyperoutes.
β¨ Creating a RequestTypeAPI Route
You can easily generate a RequestTypeAPI route using the CLI command:
Then follow the prompts:
Enter the route name:
test2Is it dynamic?
noSelect request type:
GETIs this an API Route?
yes
This will create a file named:
π§βπ» Example Code
Edit the generated file and add the following:
π Response Comparison
π§ͺ Standard RequestType Route:
β
RequestTypeAPI Route:
π Summary
RequestTypeAPI Routes provide a clean, minimal, and efficient way to build APIs inside INEX SPA. They are especially useful for frontend frameworks, mobile apps, and AJAX calls where only the raw data is needed without additional JS dependencies.
Make sure to use the _api suffix in your route file name to activate this mode.
Happy Coding with INEX SPA! β‘
Last updated