The core of any Leap-generated app is built with Encore.ts services. Each encore.service.ts file defines a microservice with its APIs, database connections, and business logic.

How services work

// users/encore.service.ts
import { api } from "encore.dev/api";
import { SQLDatabase } from "encore.dev/storage/sqldb";

// This creates a database for this service
const db = new SQLDatabase("users", {
  migrations: "./migrations",
});

// This creates an HTTP API endpoint
export const createUser = api(
  { method: "POST", path: "/users" },
  async (data: CreateUserRequest): Promise<User> => {
    // Your business logic here
    return await db.queryRow`
      INSERT INTO users (email, name)
      VALUES (${data.email}, ${data.name})
      RETURNING *
    `;
  }
);

What makes this special

  • Automatic infrastructure: Encore creates the database, HTTP endpoints, and connections
  • Type safety: Full TypeScript support across services with automatic validation
  • Service communication: Services can call each other with type-safe RPC
  • Built-in observability: Automatic tracing, metrics, and logging

Learn more: Encore.ts handles all the infrastructure complexity so you can focus on business logic. See how services work →