Configurations
On this page, you will find all available configuration properties along with their descriptions and functionalities.
nameCopied!
The name property is required and used for identification purposes and for display.
{
name: "universe-api"
}
portCopied!
The port property is set to 3000 by default and specifies the port on which the API will run.
{
port: 8080
}
prefixCopied!
The prefix property is set to an empty string by default. It determines where your API will be accessible. For example, if you set it to "/api", your API endpoints will be available at: localhost:3000/api/{endpoint}
{
prefix: "/api"
}
endpointsCopied!
The endpoints property in the configuration is an array that holds information about each endpoint. Below is an example of all the properties this configuration object can have.
{
name: "students",
methods: [
"GET",
"GET_BY_ID",
"POST",
"PUT",
"PATCH",
"DELETE"
],
objectReference: {
// read more about the available types in the Types docs
},
interceptCreations: (data, event) => {
data.name = data.name.toUpperCase();
},
interceptUpdates: (data, event) => {
data.age = data.age + 1;
}
}
name
The name property is required and must be unique. It cannot conflict with any other endpoint.
methods
The methods property is required. There are six methods that can be generated for an endpoint:
-
GET – A simple GET endpoint that retrieves all records.
-
GET_BY_ID – A GET endpoint that retrieves a single entry based on its ID.
-
POST – An endpoint for creating a new object according to the objectReference configuration.
-
PUT – An endpoint that accepts the entire object and replaces the existing one.
-
PATCH – An endpoint that updates one or more properties of an existing object without overwriting the entire record.
-
DELETE – An endpoint that accepts an ID and removes the corresponding record from the dataset.
objectReference
The objectReference is required and essential for understanding the data structure of the endpoint. For more details, refer to the Types Documentation.
interceptCreations
The interceptCreations property accepts a function that takes data and event as parameters. This method is executed before storing data in a POST request, allowing you to modify or override data or implement logging.
The event object provides the following data:
|
property |
description |
|---|---|
|
id |
The ID that the object is going to be assigned. |
interceptUpdates
The interceptUpdates property accepts a function that takes data and event as parameters. This method is executed before updating data in a PUT and PATCH requesst, allowing you to modify or override data or implement logging.
The event object provides the following data:
|
property |
description |
|---|---|
|
id |
The ID that the object is going to be assigned. |
|
method |
The HTTP method used in the request, either "PUT" or "PATCH". |