Skip to content

Template

Source: src/Railway/Template.ts

A Railway.Template deploys a marketplace template into a Project. Alchemy looks up the template (template / templates), sends templateDeployV2 with its serializedConfig, and adopts the project/services the workflow creates.

Pass a Project to deploy into an existing one. Omit project and Alchemy creates an owned Project first (the workspace project-create cap is serialized).

templateId is a marketplace UUID or code (postgres). Pass a Project to deploy into it.

const site = yield* Railway.Project("Site");
const db = yield* Railway.Template("Postgres", {
templateId: "postgres",
project: site,
});

Omit project to let Alchemy create one. The name is stamped so nuke can reclaim it.

const db = yield* Railway.Template("Postgres", {
templateId: "postgres",
});

Omit serializedConfig to use the marketplace default. Pass a config (from template.serializedConfig, with service variable values filled in) to override.

const db = yield* Railway.Template("Postgres", {
templateId: "postgres",
project: site,
serializedConfig: config,
});

Defaults to the Project’s primary environment.

const staging = yield* Railway.Environment("Staging", { project: site });
const db = yield* Railway.Template("StagingPostgres", {
templateId: "postgres",
project: site,
environment: staging,
});

Resource-valued props accept the resource or an Effect producing it.

src/db.ts
import * as Railway from "alchemy/Railway";
export const Site = Railway.Project("Site");
export const Postgres = Railway.Template("Postgres", {
templateId: "postgres",
project: Site,
});