Installation
Thanks to AxiSpark.js, you can easily install the Http Plugin in your project. Follow the steps below to get started.
Controllers
A controller is a class that handles HTTP requests and responses. It is responsible for processing incoming requests, executing business logic, and returning appropriate responses. Controllers are typically associated with specific routes or endpoints in your application.
Parameters
Http Plugin provides a set of decorators implemented through the @axisparkjs/engine package that allow you to extract parameters from the request and validate them. These decorators can be used in your controller methods to easily access and validate request parameters.
Responses
AxiSpark Http Plugin provides 3 ways to send responses to the client. Let's explore each of them in detail.
Middlewares, Guards, etc
AxiSpark.js has a powerful and flexible engine system that allows you to add custom logic to your application. This system is built for all Transport (RabbitMQ, Kafka, gRPC, GraphQL, etc), not only for Http. This is the reason why these Middlewares, Guards, etc are not specific to Http, but they can be used in Http as well. If you want to learn more about the engine system, please check the Engine System documentation.
Rate limiting
The HTTP plugin can limit requests in memory with a sliding time window. It is disabled by default. Enable it in the plugin options to apply the configured defaults to every endpoint:
Versioning
The Http Plugin provides a versioning mechanism that allows you to manage different versions of your API endpoints. This is particularly useful when you need to introduce breaking changes or new features without affecting existing clients.
File uploads
The HTTP plugin can receive files sent as multipart/form-data. It is disabled by default. Enable it in the plugin options and configure the default limits applied to every endpoint: