Skip to main content

Backend Deployment

Genezio offers a seamless and efficient solution for deploying backend logic. The platform leverages a function-as-a-service infrastructure, allowing users to deploy their backend classes easily with a simple command: genezio deploy.

tip

You can deploy classes written in TypeScript, JavaScript, Go (experimental) and Dart (experimental).

warning

We do not recommend you to manually create your projects. You should instead use the genezio create command to create a new project. This command will generate a project with the correct structure and configuration files.

Check out this tutorial to learn how to create-your-first-project with genezio.

Code Structure

To deploy with genezio, your code has to be structured in classes. Each public method of the class will be deployed as a separate function.

The following snippet of code shows a simple HelloWorldService class:

service.ts
import { GenezioDeploy } from "@genezio/types";

@GenezioDeploy()
export class HelloWorldService {
hello(name: string, sender: string): string {
console.log(`Hello world request received with name ${name} from ${sender}!`);

return `Hello, ${name}, from ${sender}!`;
}
}

Configuration file

The genezio.yaml configuration file is the file that genezio uses to understand how to deploy your project. It contains information about the project, such as the name, region, and the backend details.

genezio.yaml
# Learn more about Genezio YAML at https://genezio.com/docs/project-structure/genezio-configuration-file/
# The name of the project.
name: my-backend
# The region where the project is deployed.
region: us-east-1
# The version of the Genezio YAML configuration to parse.
yamlVersion: 2
backend:
# The root directory of the backend.
path: .
# Information about the backend's programming language.
language:
# The name of the programming language.
name: ts
# The node runtime version. (specific to js/ts)
runtime: nodejs20.x
# The classes to be deployed.
classes:
- path: service.ts
tip

The classes field can be omitted if the classes are decorated with @GenezioDeploy(). Learn more about decorators in the Decorators section.

If a class is neither decorated or specified in the genezio.yaml file, it will not be deployed.

For more details on the genezio.yaml configuration file features, check the Genezio Configuration File section.

Deploy your project

After you have written your classes and configured the genezio.yaml file, you can deploy your project by running the following command:

Terminal
genezio deploy

Testing

After deploying, you can make requests to the remote server by:

  • using the testing functionality from the genezio dashboard
  • building a client application that uses the generated type safe SDK - such as a React app or a CLI
    • Check the Generated Sdk section to find out how to use the Genezio SDK in your project.

Next Steps

Now let's see how to schedule the execution of a function as a cron job, or implement HTTP Webhooks:

Now you are ready for some more advanced use cases: