Documentation
Feedback
Guides
App Development

App Development
Service

In the VTEX IO ecosystem, services play a crucial role by allowing you to run .NET and Node.js code directly on VTEX servers. Services enable VTEX IO apps to export HTTP routes, GraphQL resolvers, and event handlers to the server.

Developing services

To create and export services, you need to specify the node or dotnet builders in your app's manifest.json file. Additionally, GraphQL services can be exported using the graphql builder.

For a practical example, refer to our service example apps: Node.js, .NET, and GraphQL.

For more information, check the Developing services on VTEX IO course in the VTEX Learning Center.

Configuring services

The configuration of your service depends on the selected builder (node or dotnet). You will find the service.json file in the /node or /dotnet folder of your app. This configuration file is responsible for defining essential parameters, including timeout, memory allocation, routes, event handlers, and replicas.

Here's an example of a service.json file:

service.json

_13
{
_13
"memory": 256,
_13
"ttl": 10,
_13
"timeout": 2,
_13
"minReplicas": 2,
_13
"maxReplicas": 4,
_13
"routes": {
_13
"status": {
_13
"path": "/_v/status/:code",
_13
"public": true
_13
}
_13
}
_13
}

Service configuration parameters

Let's delve into the parameters you can set within the service.json file:

NameTypeDescription
eventsobjectMaps an event handler to an object that describes the sender or keys.
maxReplicasnumberDefines the maximum number of replicas available.
minReplicasnumberDefines the minimum number of replicas available when the service is running.
memorynumberAllocates the specified memory size (in MB) allocated to the service.
routesobjectMaps route handlers to objects containing information about the route, such as path and public.
timeoutnumberSets the timeout (in seconds) for aborting a connection if a request takes too long.
ttlnumberDefines the time-to-live (in minutes) for how long the platform will keep the service running without receiving new requests (Default: 10 minutes; minimum: 10 minutes; maximum: 60 minutes).
workersnumberSpecifies the number of workers to spawn for the service on production. (maximum: 4).

Note that most of these fields are optional, and default values provided by the platform are often sufficient.

Contributors
3
Photo of the contributor
Photo of the contributor
Photo of the contributor
+ 3 contributors
Was this helpful?
Yes
No
Suggest edits (Github)
Contributors
3
Photo of the contributor
Photo of the contributor
Photo of the contributor
+ 3 contributors
On this page