Skip to content

Backend

Layeron backends are declared in TypeScript.

A backend project has one project config and one or more backend entry files:

  • layeron.config.ts points Layeron at the backend entry and defines environment values.
  • The backend entry exports a backend(...) app with modules, routes, middleware, and native Cloudflare declarations.
Terminal window
import { project } from "@layeron/core"
export default project({
app: "./src/app.ts",
})
Terminal window
import { backend } from "@layeron/core"
import { db, log, storage } from "@layeron/modules"
const app = backend({
project: "billing",
compatibilityDate: "2026-05-24",
})
const database = db({ name: "main" })
const files = storage.bucket({ name: "uploads" })
const appLog = log({ namespace: "app", name: "billing" })
app.use(database)
app.use(files)
app.use(appLog)
app.get("/api/health", () => ({ ok: true }))
export default app

Layeron compiles this backend into an AppSpec, RuntimeTopology, resource graph, deployment plan, and deployment state.

Use project({ backends }) when one project has several backend entry files. All entries compile into the same project resource graph for the selected environment. Equal module declarations share one logical resource.