API Routes
Last updated
Last updated
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.
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).
RequestTypeAPI Route files follow this pattern:
Where:
[route]
is your route name (e.g., test2
).
[METHOD]
is the HTTP method (GET
, POST
, etc).
The _api
suffix distinguishes it from standard RequestType
routes.
You can easily generate a RequestTypeAPI route using the CLI command:
Then follow the prompts:
Enter the route name: test2
Is it dynamic? no
Select request type: GET
Is this an API Route? yes
This will create a file named:
Edit the generated file and add the following:
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! โก