Comment on page


Deploying a class with genezio

The main unit of deployment in JavaScript is a class. The methods of your class can be called using the following ways:
Below you can see a basic example of a JavaScript class deployed using genezio.
// hello.js
export class HelloWorldService {
constructor() {
console.log("Constructor called!")
helloWorld() {
return "Hello world!";
hello(name, from) {
return `Hello, ${name}, from ${from}!`
Let's break down the code:
constructor() - this method is called once for every function instance spawned in the cloud. This method is not called for every request.
helloWorld() - receives no parameters and returns a string.
hello() - receives two parameters and returns a string.
Notice that the class HelloWorldService is exported. All of your exported classes will be exposed to the client using the autogenerated SDK.

Genezio configuration file

To deploy this class, you also need a genezio.yaml configuration file. Learn more about which configuration fields you can tweak.
# genezio.yaml
name: hello-world
region: us-east-1
language: js
runtime: node
path: ../client/sdk/
- path: ./hello.js
type: jsonrpc