Skip to content

Developing a Transformer

Using the NodeJS Template

To develop a transformer, you can use the NodeJS template. This template is a simple NodeJS application that you can use to develop your transformer, and then deploy it to Flowcore.

Go to https://github.com/flowcore-io/nodejs-typescript-transformer-example and click on the “Use this template” button to create a new repository based on the template.

What is a Transformer?

A transformer is a piece of code that takes an event from a data stream and transforms it into some other format. A Flowcore transformer expects these HTTP endpoints.

  • /health: A health check endpoint that returns a 200 status code if the transformer is healthy.
  • /transform: The endpoint that receives the event data and transforms it.
  • /reset: An endpoint that resets the transformer.

Returning status codes

If you want to retry events you can return HTTP status codes from the transform endpoint.

These are the status codes that you can return and the transform will be retried.

408, 429, 425, 429, 502, 503, 504

Pause the Data stream

If you want to pause the data stream, you can return a 429 status code from the transform endpoint.

Retry-After

If you return a 429 status code, you need to also return a Retry-After header with the number of seconds to wait before retrying the event.

Using the transformer

To use the transformer you need to specify a url to the runtime archive in either the Flowcore UI or the Flowcore Manifest.