Skip to content

Services

Roli hosts serverless cloud backends called Services that your applications can access at runtime using automatically generated client code.

Service Code

Services are comprised of functions and POJOs (Plain Old JavaScript Objects) written in TypeScript.

Service Creation

To create a service, create a new folder and initialize it. Initializing creates a service.json file inside the folder that contains the service’s name and other service metadata.

To initialize a service you use the init-service command, passing the directory and the service’s name

Terminal window
$ mkdir my-service
$ cd my-service
$ roli init-service my-service-name

You can only initialize a service once.

Service Deployment

Once the service code is written, or you’ve made code changes, you must deploy it to Roli before it can be used.

To deploy your service code changes use the deploy-service command in the service directory:

Terminal window
$ cd my-service
$ roli deploy-service

Or you can specify the -d option to specify the service directory to deploy:

Terminal window
$ roli deploy-service -d my-service

The deploy-service command deploys the service if it finds there are changes to deploy. This makes it safe to use this command in CI scripts.

However, if there’s a need to override the change detection, use the —force option:

Terminal window
$ roli deploy-service --force

Service Version

Each time you deploy your service it increments the service version number. Doing so ensures clients can’t use out of date service code, preventing certain types of data corruption.

Listing Deployed Services

You can show the list of services, along with their versions, that have been deployed using the list-services command.

Terminal window
roli list-services

Renaming Services

You can change the name of your service using this process:

  1. Change the name of the service in the service.json file in the service code directory.
  2. Deploy the service to complete the renaming.