### Create Full Connection Setup Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/prisma-postgres/connection.md This example demonstrates creating a complete setup including a project, database, and connection. It shows how to link these resources together. ```typescript import { Project, Database, Connection } from "alchemy/prisma-postgres"; const project = await Project("my-app"); const database = await Database("production", { project: project, }); const connection = await Connection("app-connection", { database: database, name: "production-api-connection" }); console.log(`Host: ${connection.host}`); console.log(`User: ${connection.user}`); console.log(`Password: ${connection.password?.unencrypted}`); console.log(`Connection String: ${connection.connectionString.unencrypted}`); ``` -------------------------------- ### Create Account with Basic Setup Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/coinbase/evm-account.md Standard account creation example showing how to access the account address. ```typescript import { EvmAccount } from "alchemy/coinbase"; const account = await EvmAccount("my-account", { name: "my-wallet" }); console.log("Account address:", account.address); ``` -------------------------------- ### Install Dependencies and Run Locally Source: https://github.com/alchemy-run/alchemy/blob/main/examples/cloudflare-livestore/README.md Installs project dependencies using bun and starts the local development server. Alternatively, deploy to Cloudflare. ```bash bun install bun dev # run locally bun run deploy # or deploy to Cloudflare ``` -------------------------------- ### Install project dependencies Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/nuxt/README.md Run these commands to install the necessary project dependencies before starting development. ```bash # npm npm install # pnpm pnpm install # yarn yarn install # bun bun install ``` -------------------------------- ### Run development server Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/sveltekit/README.md Start the development server after installing dependencies. Use the --open flag to automatically launch the app in a browser. ```bash npm run dev # or start the server and open the app in a new browser tab npm run dev -- --open ``` -------------------------------- ### Complete Internet Setup with Routing Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws/internet-gateway-attachment.md This comprehensive example sets up a VPC, Internet Gateway, attaches them, and configures routing for internet connectivity. It includes creating a public subnet and associating it with a route table pointing to the Internet Gateway. ```typescript import { Vpc, InternetGateway, InternetGatewayAttachment, Subnet, RouteTable, Route, RouteTableAssociation } from "alchemy/aws/ec2"; // Create VPC with DNS enabled const vpc = await Vpc("web-vpc", { cidrBlock: "10.0.0.0/16", enableDnsHostnames: true, enableDnsSupport: true, tags: { Name: "web-vpc", Environment: "production" } }); // Create Internet Gateway const igw = await InternetGateway("web-igw", { tags: { Name: "web-internet-gateway" } }); // Attach Internet Gateway to VPC const attachment = await InternetGatewayAttachment("web-igw-attachment", { internetGateway: igw, vpc: vpc }); // Create public subnet const publicSubnet = await Subnet("public-subnet", { vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a", mapPublicIpOnLaunch: true, tags: { Name: "public-subnet-1a", Type: "public" } }); // Create route table for public access const publicRouteTable = await RouteTable("public-rt", { vpc, tags: { Name: "public-route-table" } }); // Add route to Internet Gateway (depends on attachment) const internetRoute = await Route("internet-route", { routeTable: publicRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { internetGateway: igw } }); // Associate subnet with route table const routeAssociation = await RouteTableAssociation("public-association", { routeTable: publicRouteTable, subnet: publicSubnet }); ``` -------------------------------- ### Start Development Server Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/tanstack-start/README.md Execute this command to start the development server. ```bash bunx --bun run start ``` -------------------------------- ### Navigate to example directory Source: https://github.com/alchemy-run/alchemy/blob/main/examples/cloudflare-sveltekit/README.md Change the working directory to the Cloudflare SvelteKit example folder. ```bash cd examples/cloudflare-sveltekit ``` -------------------------------- ### Multi-AZ Public Infrastructure Setup Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws/internet-gateway-attachment.md This example demonstrates setting up a highly available internet infrastructure across multiple Availability Zones. It includes creating a VPC, an Internet Gateway, attaching it, and configuring a single route table for multiple public subnets across different AZs. ```typescript import { Vpc, InternetGateway, InternetGatewayAttachment, Subnet, RouteTable, Route, RouteTableAssociation } from "alchemy/aws/ec2"; const vpc = await Vpc("ha-vpc", { cidrBlock: "10.0.0.0/16", enableDnsHostnames: true, enableDnsSupport: true }); const igw = await InternetGateway("ha-igw", { tags: { Name: "high-availability-igw" } }); const attachment = await InternetGatewayAttachment("ha-igw-attachment", { internetGateway: igw, vpc: vpc }); // Public subnets in multiple availability zones const publicSubnet1a = await Subnet("public-subnet-1a", { vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a", mapPublicIpOnLaunch: true }); const publicSubnet1b = await Subnet("public-subnet-1b", { vpc, cidrBlock: "10.0.2.0/24", availabilityZone: "us-east-1b", mapPublicIpOnLaunch: true }); const publicSubnet1c = await Subnet("public-subnet-1c", { vpc, cidrBlock: "10.0.3.0/24", availabilityZone: "us-east-1c", mapPublicIpOnLaunch: true }); // Single route table for all public subnets const publicRouteTable = await RouteTable("public-rt", { vpc: vpc }); const internetRoute = await Route("internet-route", { routeTable: publicRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { internetGateway: igw } }); // Associate all public subnets const association1a = await RouteTableAssociation("public-association-1a", { routeTable: publicRouteTable, subnet: publicSubnet1a }); const association1b = await RouteTableAssociation("public-association-1b", { routeTable: publicRouteTable, subnet: publicSubnet1b }); const association1c = await RouteTableAssociation("public-association-1c", { routeTable: publicRouteTable, subnet: publicSubnet1c }); ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/hono/README.md Use 'bun install' to install all necessary project dependencies. ```bash bun install ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/alchemy-run/alchemy/blob/main/examples/cloudflare-nuxt-pipeline/README.md Change your current directory to the specific example folder before running deployment or development commands. ```bash cd examples/nuxt3-basic ``` -------------------------------- ### Complete VPC Setup with Internet Gateway Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws/internet-gateway.md This comprehensive example demonstrates setting up a VPC, Internet Gateway, public subnet, route table, and associated routes for internet connectivity. It requires importing multiple EC2 components from 'alchemy/aws/ec2'. ```typescript import { Vpc, InternetGateway, InternetGatewayAttachment, Subnet, RouteTable, Route, RouteTableAssociation } from "alchemy/aws/ec2"; // Create VPC const vpc = await Vpc("web-vpc", { cidrBlock: "10.0.0.0/16", enableDnsHostnames: true, enableDnsSupport: true }); // Create Internet Gateway const igw = await InternetGateway("web-igw", { tags: { Name: "web-internet-gateway" } }); // Attach Internet Gateway to VPC const attachment = await InternetGatewayAttachment("web-igw-attachment", { internetGateway: igw, vpc: vpc }); // Create public subnet const publicSubnet = await Subnet("public-subnet", { vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a", mapPublicIpOnLaunch: true }); // Create route table for public subnet const publicRouteTable = await RouteTable("public-rt", { vpc, tags: { Name: "public-route-table" } }); // Add route to Internet Gateway const internetRoute = await Route("internet-route", { routeTable: publicRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { internetGateway: igw } }); // Associate subnet with route table const routeAssociation = await RouteTableAssociation("public-association", { routeTable: publicRouteTable, subnet: publicSubnet }); ``` -------------------------------- ### Start Development Server Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/rwsdk/README.md Launch the local development environment. ```shell pnpm dev ``` -------------------------------- ### Configure Comprehensive Default Settings Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/cloudflare/warp-default-profile.md This example shows how to configure all available default WARP client settings for a comprehensive setup. ```APIDOC ## Configure Comprehensive Default Settings ### Description Configures all available default WARP client settings, providing a complete setup. ### Method POST (or PUT) ### Endpoint /api/v1/accounts/{account_id}/warp/default-profile ### Parameters #### Request Body - **serviceModeV2** (object) - Required - WARP client operational mode. Example: `{ "mode": "warp" }` - **disableAutoFallback** (boolean) - Optional - Disable automatic fallback to direct connection. - **allowModeSwitch** (boolean) - Optional - Allow users to manually switch WARP modes. - **switchLocked** (boolean) - Optional - Lock the WARP toggle switch. - **tunnelProtocol** (string) - Optional - Tunnel protocol to use: `"wireguard"` or `"masque"`. - **autoConnect** (number) - Optional - Auto-connect timeout in seconds (0 to disable). - **allowedToLeave** (boolean) - Optional - Allow users to disconnect from WARP. - **captivePortal** (number) - Optional - Captive portal timeout in seconds. - **supportUrl** (string) - Optional - Support URL for feedback button. - **excludeOfficeIps** (boolean) - Optional - Exclude office IPs from WARP tunnel. - **lanAllowMinutes** (number) - Optional - LAN allow duration in minutes. - **lanAllowSubnetSize** (number) - Optional - LAN subnet size for local network access. - **splitTunnel** (object) - Optional - Split tunnel configuration. - **mode** (string) - Required - Split tunnel mode: `"exclude"` or `"include"`. - **entries** (array) - Required - Array of routes to include or exclude. - **address** (string) - Required - IP address/CIDR or domain. - **description** (string) - Optional - Description for the route entry. ### Request Example ```json { "serviceModeV2": { "mode": "warp" }, "disableAutoFallback": false, "allowModeSwitch": false, "switchLocked": true, "tunnelProtocol": "wireguard", "autoConnect": 0, "allowedToLeave": false, "captivePortal": 180, "supportUrl": "https://support.example.com", "excludeOfficeIps": true, "lanAllowMinutes": 5, "lanAllowSubnetSize": 24 } ``` ### Response #### Success Response (200) - **serviceModeV2** (object) - WARP client operational mode. - **disableAutoFallback** (boolean) - Indicates if fallback to direct connection is disabled. - **allowModeSwitch** (boolean) - Indicates if users can switch WARP modes. - **switchLocked** (boolean) - Indicates if the WARP toggle is locked. - **tunnelProtocol** (string) - The tunnel protocol used. - **autoConnect** (number) - Auto-connect timeout in seconds. - **allowedToLeave** (boolean) - Indicates if users can disconnect from WARP. - **captivePortal** (number) - Captive portal timeout in seconds. - **supportUrl** (string) - Support URL for feedback button. - **excludeOfficeIps** (boolean) - Indicates if office IPs are excluded from WARP. - **lanAllowMinutes** (number) - LAN allow duration in minutes. - **lanAllowSubnetSize** (number) - LAN subnet size. - **splitTunnel** (object) - Split tunnel configuration. #### Response Example ```json { "serviceModeV2": { "mode": "warp" }, "disableAutoFallback": false, "allowModeSwitch": false, "switchLocked": true, "tunnelProtocol": "wireguard", "autoConnect": 0, "allowedToLeave": false, "captivePortal": 180, "supportUrl": "https://support.example.com", "excludeOfficeIps": true, "lanAllowMinutes": 5, "lanAllowSubnetSize": 24 } ``` ``` -------------------------------- ### Navigate to Docker Example Directory Source: https://github.com/alchemy-run/alchemy/blob/main/examples/docker/README.md Command to change the current directory to the location of the Docker provider example. ```bash cd examples/docker ``` -------------------------------- ### Multi-Tenant Architecture Setup Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/cloudflare/dispatch-namespace.md Demonstrates a complete setup including KV storage, multiple tenant-specific workers, and a main platform router. ```ts import { Worker, DispatchNamespace, KVNamespace, Json, } from "alchemy/cloudflare"; // Create a dispatch namespace for tenant workers const tenants = await DispatchNamespace("tenants", { namespace: "customer-workers", }); // Create KV namespace for tenant metadata const tenantData = await KVNamespace("tenant-data", { title: "Tenant Configuration", }); // Deploy tenant-specific workers const tenantWorkerA = await Worker("tenant-a", { name: "customer-a-worker", entrypoint: "./src/tenant-worker.ts", namespace: tenants, bindings: { CONFIG: Json({ customerId: "customer-a", features: ["feature1", "feature2"], }), }, }); const tenantWorkerB = await Worker("tenant-b", { name: "customer-b-worker", entrypoint: "./src/tenant-worker.ts", namespace: tenants, bindings: { CONFIG: Json({ customerId: "customer-b", features: ["feature1", "feature3"], }), }, }); // Create the main router that handles all tenant requests const mainRouter = await Worker("main-router", { name: "platform-router", entrypoint: "./src/main-router.ts", bindings: { TENANT_NAMESPACE: tenants, TENANT_DATA: tenantData, }, routes: [ { pattern: "*.platform.example.com/*", }, ], }); ``` -------------------------------- ### Start development server Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/nuxt/README.md Launch the local development server to view the application at http://localhost:3000. ```bash # npm npm run dev # pnpm pnpm dev # yarn yarn dev # bun bun run dev ``` -------------------------------- ### Initialize TanStack Start project Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/guides/cloudflare-tanstack-start.mdx Create a new project using the TanStack Start template with your preferred package manager. ```sh bunx alchemy create my-tanstack-app --template=tanstack-start cd my-tanstack-app ``` ```sh npx alchemy create my-tanstack-app --template=tanstack-start cd my-tanstack-app ``` ```sh pnpm dlx alchemy create my-tanstack-app --template=tanstack-start cd my-tanstack-app ``` ```sh yarn dlx alchemy create my-tanstack-app --template=tanstack-start cd my-tanstack-app ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/nextjs/README.md Run this command to install all necessary project dependencies. ```bash npm install ``` -------------------------------- ### Example Deployment Output Source: https://github.com/alchemy-run/alchemy/blob/main/AGENTS.md This is an example of the expected output after a successful deployment. Review the logged information for interacting with your deployed app. ```sh {expected output} ``` -------------------------------- ### Create Global Setup Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/concepts/testing.mdx Implement the global setup to deploy infrastructure and provide context to tests. ```typescript /// import type { TestProject } from "vitest/node"; export async function setup({ provide }: TestProject) { // Import and run your alchemy app const { app, worker } = await import("./alchemy.run.ts"); if (!worker.url) { throw new Error("worker.url is not defined"); } // Provide values to your tests provide("workerUrl", worker.url); // Return cleanup function return async () => { await app.cleanup(); }; } // Declare the provided context for type safety declare module "vitest" { export interface ProvidedContext { workerUrl: string; } } ``` -------------------------------- ### Start Development Server Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/guides/turborepo.mdx Run this command from the project root to start the development server for the frontend app. A turborepo TUI will appear. ```sh bun dev ``` ```sh npm run dev ``` ```sh yarn dev ``` ```sh pnpm dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/alchemy-run/alchemy/blob/main/CONTRIBUTING.md Installs all project dependencies using Bun workspaces. Run this after cloning the repository. ```sh bun i ``` -------------------------------- ### Deploy Command Examples Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/concepts/cli.mdx Common usage patterns for the deploy command. ```sh # deploy the default stage alchemy deploy # specify a stage alchemy deploy --stage prod # deploy the default stage alchemy deploy --profile prod # adopt existing resources alchemy deploy --adopt # use a custom script alchemy deploy ./my-infra.ts # use an environment file alchemy deploy --env-file .env.prod # watch and deploy changes to the cloud alchemy deploy --watch # force update all resources even without changes alchemy deploy --force # recover from lost encryption password by erasing secrets alchemy deploy --force --erase-secrets ``` -------------------------------- ### Install Dependencies with Bun Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/guides/prisma-d1.mdx Installs necessary dependencies including Alchemy, Prisma client, and adapter for Bun. ```sh bun init -y bun add alchemy @prisma/client @prisma/adapter-d1 bun add -D prisma @types/node @cloudflare/workers-types typescript ``` -------------------------------- ### Run local development server Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/what-is-alchemy.md Start the development environment with hot reloading. ```bash bun ./alchemy.run.ts --dev ``` -------------------------------- ### Provider Getting Started Guide Structure Source: https://github.com/alchemy-run/alchemy/blob/main/AGENTS.md Defines the front matter and initial content structure for a provider's getting started guide. It includes ordering, title, description, and a brief overview of the tutorial's objective. ```markdown --- order: { number to decide the position in the tree view } title: { Provider } description: { concise description of the tutorial } --- # Getting Started {Provider} {1 sentence overview of what this tutorial will set the user up with} ``` -------------------------------- ### Minimal AiSearchNamespace Setup Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/cloudflare/ai-search-namespace.md Demonstrates the basic setup for creating an AiSearchNamespace. Ensure you have the correct version of `@cloudflare/workers-types` installed. ```typescript import { AiSearchNamespace } from "alchemy/cloudflare"; const ns = await AiSearchNamespace("production", { name: "production", }); ``` -------------------------------- ### Initialize a New Project with a Provider Source: https://github.com/alchemy-run/alchemy/blob/main/AGENTS.md Run these commands to initialize a new project and set up the specified provider. ```sh bun ./alchemy.run init ``` ```sh npm exec tsx ./alchemy.run init ``` ```sh pnpm exec tsx ./alchemy.run init ``` ```sh yarn dlx tsx ./alchemy.run init ``` -------------------------------- ### Initialize project directory Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/guides/drizzle-d1.mdx Create the project folder and navigate into it. ```sh mkdir drizzle-d1-app cd drizzle-d1-app ``` -------------------------------- ### Start Local Service Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/guides/cloudflare-tunnel.mdx Ensure your local application is running on the port specified in the tunnel's ingress rules. Examples include starting a simple HTTP server or running your application directly. ```bash # Example: Start a simple HTTP server on port 3000 npx http-server -p 3000 # Or run your application # node app.js # python -m http.server 3000 # etc. ``` -------------------------------- ### Configure Vite for TanStack Start and Alchemy Cloudflare Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/blog/2025-08-05-alchemy-vite-plugin.md This configuration updates the vite.config.ts file to include the Alchemy Cloudflare TanStack Start plugin and removes deprecated build configurations. Ensure you have the necessary Alchemy and TanStack packages installed. ```typescript import { tanstackStart } from "@tanstack/react-start/plugin/vite"; import viteReact from "@vitejs/plugin-react"; import alchemy from "alchemy/cloudflare/tanstack-start"; import { defineConfig } from "vite"; import tsConfigPaths from "vite-tsconfig-paths"; export default defineConfig({ server: { port: 3000, }, plugins: [ alchemy(), tsConfigPaths({ projects: ["./tsconfig.json"], }), tanstackStart(), viteReact(), ], }); ``` -------------------------------- ### Enable Email Routing (Minimal) Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/cloudflare/email-routing.md Enable email routing for your domain with minimal configuration. This is the most straightforward way to get started. ```typescript import { EmailRouting } from "alchemy/cloudflare"; await EmailRouting("my-email-routing", { zone: "example.com", enabled: true, }); ``` -------------------------------- ### Minimal Email Binding Setup Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/cloudflare/email-sender.md Configure a basic email binding for your Worker using EmailSender(). This is the starting point for sending emails. ```typescript import { EmailSender, Worker } from "alchemy/cloudflare"; const worker = await Worker("mailer", { name: "mailer", entrypoint: "./src/worker.ts", bindings: { EMAIL: EmailSender(), }, }); ``` -------------------------------- ### Astro Development Commands Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/astro/README.md These commands are essential for managing your Astro project. They cover installation, starting the development server, building for production, and previewing the build. ```sh bun install ``` ```sh bun dev ``` ```sh bun build ``` ```sh bun preview ``` ```sh bun astro ... ``` ```sh bun astro -- --help ``` -------------------------------- ### Complete DataProvider Configuration Example Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/dms/data-provider.md Demonstrate a complete configuration with a variety of settings, including connection details and tags. Replace placeholder settings with actual values. ```typescript const completeDataProvider = await AWS.DMS.DataProvider("completeDataProvider", { Engine: "mongodb", DataProviderName: "MyMongoDBDataProvider", Description: "Full configuration for MongoDB", ExactSettings: true, Settings: { // Example settings structure, replace with actual settings as needed "MongodUri": "mongodb://username:password@host:port/dbname" }, Tags: [ { Key: "Department", Value: "IT" }, { Key: "Owner", Value: "DataTeam" } ] }); ``` -------------------------------- ### Create an Advanced AppBlock with Scripts Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/app-stream/app-block.md This example shows how to configure an AppBlock with setup and post-setup scripts, including their S3 locations and timeouts, along with tags. ```APIDOC ## POST /api/appblocks ### Description Creates an AWS AppStream AppBlock with advanced configurations, including setup and post-setup scripts, and tags. ### Method POST ### Endpoint /api/appblocks ### Request Body - **Name** (string) - Required - The unique name for the AppBlock. - **SourceS3Location** (object) - Required - The S3 location of the application source. - **S3Bucket** (string) - Required - The name of the S3 bucket. - **S3Key** (string) - Required - The key (path) to the object in the S3 bucket. - **SetupScriptDetails** (object) - Optional - Details for the setup script. - **ScriptS3Location** (object) - Required - The S3 location of the setup script. - **S3Bucket** (string) - Required - The name of the S3 bucket. - **S3Key** (string) - Required - The key (path) to the script object. - **TimeoutInSeconds** (integer) - Optional - The timeout for the setup script in seconds. - **PostSetupScriptDetails** (object) - Optional - Details for the post-setup script. - **ScriptS3Location** (object) - Required - The S3 location of the post-setup script. - **S3Bucket** (string) - Required - The name of the S3 bucket. - **S3Key** (string) - Required - The key (path) to the script object. - **TimeoutInSeconds** (integer) - Optional - The timeout for the post-setup script in seconds. - **Tags** (array) - Optional - A list of tags to associate with the AppBlock. - **Key** (string) - Required - The tag key. - **Value** (string) - Required - The tag value. ### Request Example ```json { "Name": "AdvancedAppBlock", "SourceS3Location": { "S3Bucket": "my-app-bucket", "S3Key": "my-advanced-app.zip" }, "SetupScriptDetails": { "ScriptS3Location": { "S3Bucket": "my-scripts-bucket", "S3Key": "setup-script.sh" }, "TimeoutInSeconds": 300 }, "PostSetupScriptDetails": { "ScriptS3Location": { "S3Bucket": "my-scripts-bucket", "S3Key": "post-setup-script.sh" }, "TimeoutInSeconds": 300 }, "Tags": [ { "Key": "Environment", "Value": "Production" }, { "Key": "Department", "Value": "IT" } ] } ``` ### Response #### Success Response (201 Created) - **AppBlockArn** (string) - The ARN of the created AppBlock. - **Name** (string) - The name of the created AppBlock. #### Response Example ```json { "AppBlockArn": "arn:aws:appstream:us-east-1:123456789012:appblock/advancedAppBlock", "Name": "AdvancedAppBlock" } ``` ``` -------------------------------- ### Create Custom Ingest Configuration Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/ivs/ingest-configuration.md Configures an ingest setting with specific user ID and ingest protocol. This example demonstrates a custom setup for a particular stage. ```typescript const customIngestConfig = await AWS.IVS.IngestConfiguration("customIngestConfig", { userId: "user789", ingestProtocol: "RTMP", stageArn: "arn:aws:ivs:us-west-1:123456789012:stage:custom-stage", insecureIngest: false, name: "CustomIngestConfig" }); ``` -------------------------------- ### Complete R2 Notifications Setup Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/guides/cloudflare-r2-notifications.mdx This TypeScript code sets up R2 bucket notifications to send events to a queue, which then triggers a worker. Ensure you have the 'alchemy' and 'alchemy/cloudflare' modules installed. ```typescript import { alchemy } from "alchemy"; import { R2Bucket, Queue, R2BucketNotification, Worker, R2BucketNotificationMessage, } from "alchemy/cloudflare"; const app = await alchemy("r2-notifications-demo"); export const bucket = await R2Bucket("uploads"); export const queue = await Queue("upload-events"); await R2BucketNotification("upload-notifications", { bucket, queue, eventTypes: ["object-create"], prefix: "incoming/", }); export const worker = await Worker("processor", { entrypoint: "./src/processor.ts", bindings: { BUCKET: bucket, }, eventSources: [queue], url: true, }); console.log("Worker URL:", worker.url); await app.finalize(); ``` -------------------------------- ### Create a basic KnowledgeBase Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/wisdom/knowledge-base.md Initializes a standard KnowledgeBase with a name, type, and description. ```ts import AWS from "alchemy/aws/control"; const knowledgeBase = await AWS.Wisdom.KnowledgeBase("basicKnowledgeBase", { name: "CustomerSupportKB", knowledgeBaseType: "CUSTOMER_SUPPORT", description: "A knowledge base for customer support queries." }); ``` -------------------------------- ### Microservices NAT Gateway Setup Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws/nat-gateway.md Sets up a VPC, public subnet for NAT Gateway, private subnets for microservices, and associated route tables for outbound internet access. Ensure the 'alchemy/aws/ec2' module is installed. ```typescript import { Vpc, Subnet, NatGateway, RouteTable, Route, RouteTableAssociation } from "alchemy/aws/ec2"; const vpc = await Vpc("microservices-vpc", { cidrBlock: "10.0.0.0/16" }); // Public subnet for NAT Gateway const natSubnet = await Subnet("nat-subnet", { vpc: vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a", mapPublicIpOnLaunch: true, tags: { Name: "nat-subnet", Purpose: "nat-gateway" } }); // Private subnets for microservices const servicesSubnet1a = await Subnet("services-subnet-1a", { vpc: vpc, cidrBlock: "10.0.11.0/24", availabilityZone: "us-east-1a", tags: { Name: "microservices-subnet-1a", Tier: "microservices" } }); const servicesSubnet1b = await Subnet("services-subnet-1b", { vpc: vpc, cidrBlock: "10.0.12.0/24", availabilityZone: "us-east-1b", tags: { Name: "microservices-subnet-1b", Tier: "microservices" } }); // Shared services subnet const sharedSubnet = await Subnet("shared-subnet", { vpc: vpc, cidrBlock: "10.0.21.0/24", availabilityZone: "us-east-1a", tags: { Name: "shared-services-subnet", Tier: "shared-services" } }); // NAT Gateway for outbound access const microservicesNat = await NatGateway("microservices-nat", { subnet: natSubnet, tags: { Name: "microservices-nat-gateway", Architecture: "microservices", Purpose: "outbound-internet-access" } }); // Route tables and routes const servicesRouteTable = await RouteTable("services-rt", { vpc: vpc, tags: { Name: "microservices-route-table" } }); const sharedRouteTable = await RouteTable("shared-rt", { vpc: vpc, tags: { Name: "shared-services-route-table" } }); const servicesNatRoute = await Route("services-nat-route", { routeTable: servicesRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { natGateway: microservicesNat } }); const sharedNatRoute = await Route("shared-nat-route", { routeTable: sharedRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { natGateway: microservicesNat } }); // Associations const servicesAssociation1a = await RouteTableAssociation("services-association-1a", { routeTable: servicesRouteTable, subnet: servicesSubnet1a }); const servicesAssociation1b = await RouteTableAssociation("services-association-1b", { routeTable: servicesRouteTable, subnet: servicesSubnet1b }); const sharedAssociation = await RouteTableAssociation("shared-association", { routeTable: sharedRouteTable, subnet: sharedSubnet }); ``` -------------------------------- ### Create a basic SoftwarePackage Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/io-t/software-package.md Initializes a new SoftwarePackage with a name and description. ```ts import AWS from "alchemy/aws/control"; const basicSoftwarePackage = await AWS.IoT.SoftwarePackage("basicSoftwarePackage", { PackageName: "MyIoTSoftware", Description: "This package includes essential software for IoT devices." }); ``` -------------------------------- ### Build and preview project Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/sveltekit/README.md Generate a production build of the application and preview the resulting output. ```bash npm run build ``` ```bash npm run preview ``` -------------------------------- ### Create StorageLensGroup with Custom Filters and Tags Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/s3/storage-lens-group.md Define a StorageLensGroup with a complex filter setup, including prefix and tag matching, and add ownership tags. This example filters for objects with the prefix 'data/' and the tag 'Project: Alpha', and adds the tag 'Owner: DataTeam'. ```typescript const comprehensiveStorageLensGroup = await AWS.S3.StorageLensGroup("comprehensiveStorageLensGroup", { Filter: { Prefix: "data/", Tag: { Key: "Project", Value: "Alpha" } }, Name: "DataStorageLensGroup", Tags: [ { Key: "Owner", Value: "DataTeam" } ] }); ``` -------------------------------- ### Create Partitioned Glue Table for Efficient Queries Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/glue/table.md Use this example to create a partitioned Glue Table, optimizing query performance for large datasets by defining partition keys such as year, month, and day. This setup is ideal for time-series data like web logs. ```typescript const partitionedGlueTable = await AWS.Glue.Table("partitionedGlueTable", { TableInput: { Name: "web_logs", Description: "Table containing web server logs", StorageDescriptor: { Columns: [ { Name: "log_id", Type: "string" }, { Name: "ip_address", Type: "string" }, { Name: "timestamp", Type: "timestamp" }, { Name: "url", Type: "string" } ], Location: "s3://my-bucket/web_logs/", InputFormat: "org.apache.hadoop.mapred.TextInputFormat", OutputFormat: "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat", SerdeInfo: { SerializationLibrary: "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe", Parameters: { "field.delim": "," } } }, PartitionKeys: [ { Name: "year", Type: "int" }, { Name: "month", Type: "int" }, { Name: "day", Type: "int" } ] }, DatabaseName: "logs_database", CatalogId: "123456789012" }); ``` -------------------------------- ### Database Access Pattern NAT Gateway Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws/nat-gateway.md Configures a NAT Gateway for a database VPC to allow for maintenance and updates. This setup isolates database subnets by default and uses a separate route table for temporary internet access during maintenance. Ensure the 'alchemy/aws/ec2' module is installed. ```typescript import { Vpc, Subnet, NatGateway, RouteTable, Route, RouteTableAssociation } from "alchemy/aws/ec2"; const vpc = await Vpc("database-vpc", { cidrBlock: "10.0.0.0/16" }); // Public subnet for NAT Gateway const natSubnet = await Subnet("db-nat-subnet", { vpc: vpc, cidrBlock: "10.0.1.0/24", availabilityZone: "us-east-1a", mapPublicIpOnLaunch: true }); // Database subnets (normally isolated) const dbSubnet1a = await Subnet("db-subnet-1a", { vpc: vpc, cidrBlock: "10.0.11.0/24", availabilityZone: "us-east-1a", tags: { Name: "database-subnet-1a", Tier: "database" } }); const dbSubnet1b = await Subnet("db-subnet-1b", { vpc: vpc, cidrBlock: "10.0.12.0/24", availabilityZone: "us-east-1b", tags: { Name: "database-subnet-1b", Tier: "database" } }); // NAT Gateway for database maintenance access const dbMaintenanceNat = await NatGateway("db-maintenance-nat", { subnet: natSubnet, tags: { Name: "database-maintenance-nat", Purpose: "database-updates-patches", Usage: "maintenance-only" } }); // Maintenance route table (used temporarily) const maintenanceRouteTable = await RouteTable("db-maintenance-rt", { vpc: vpc, tags: { Name: "database-maintenance-route-table", Purpose: "temporary-internet-access" } }); const maintenanceNatRoute = await Route("maintenance-nat-route", { routeTable: maintenanceRouteTable, destinationCidrBlock: "0.0.0.0/0", target: { natGateway: dbMaintenanceNat } }); // Normal isolated route table (no internet access) const isolatedRouteTable = await RouteTable("db-isolated-rt", { vpc: vpc, tags: { Name: "database-isolated-route-table", Purpose: "no-internet-access" } }); // Default associations (isolated) const isolatedAssociation1a = await RouteTableAssociation("db-isolated-association-1a", { routeTable: isolatedRouteTable, subnet: dbSubnet1a }); const isolatedAssociation1b = await RouteTableAssociation("db-isolated-association-1b", { routeTable: isolatedRouteTable, subnet: dbSubnet1b }); ``` -------------------------------- ### Create a basic LaunchWizard Deployment Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/launch-wizard/deployment.md Initializes a standard deployment with required workload and instance specifications. ```ts import AWS from "alchemy/aws/control"; const basicDeployment = await AWS.LaunchWizard.Deployment("basicDeployment", { WorkloadName: "MyWebApp", DeploymentPatternName: "Single-AZ", Name: "MyWebAppDeployment", Specifications: { InstanceType: "t3.medium", Database: { Engine: "mysql", Version: "8.0", Storage: 20 } }, Tags: [ { Key: "Environment", Value: "Production" }, { Key: "Team", Value: "DevOps" } ] }); ``` -------------------------------- ### Run Development Server Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/hono/README.md Use 'bun run dev' to start the local development server. ```bash bun run dev ``` -------------------------------- ### Create a basic WebExperience Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/qbusiness/web-experience.md Initializes a WebExperience with essential properties including application ID, title, origins, and a welcome message. ```ts import AWS from "alchemy/aws/control"; const basicWebExperience = await AWS.QBusiness.WebExperience("basicWebExperience", { applicationId: "app-123456", title: "Basic Web Experience", origins: ["https://example.com"], welcomeMessage: "Welcome to our basic web experience!" }); ``` -------------------------------- ### Deploy Web App with Redis and Custom Images using Docker Provider Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/docker/index.md This example demonstrates a full setup of a web application with Redis, custom Docker images, and persistent volumes using the Alchemy Docker provider. It covers network creation, volume management, pulling remote images, building custom images, and running containers with specific configurations. ```typescript import * as docker from "alchemy/docker"; // Create a Docker network const network = await docker.Network("app-network", { name: "my-application-network" }); // Create a persistent volume for Redis data const redisVolume = await docker.Volume("redis-data", { name: "redis-data", labels: [ { name: "app", value: "my-application" }, { name: "service", value: "redis" } ] }); // Pull Redis image const redisImage = await docker.RemoteImage("redis-image", { name: "redis", tag: "alpine" }); // Run Redis container with persistent volume const redis = await docker.Container("redis", { image: redisImage.imageRef, name: "redis", networks: [{ name: network.name }], volumes: [ { hostPath: redisVolume.name, containerPath: "/data" } ], start: true }); // Build a custom application image from local Dockerfile const appImage = await docker.Image("app-image", { name: "my-web-app", tag: "latest", build: { context: "./app", buildArgs: { NODE_ENV: "production" } } }); // Create a volume for application logs const logsVolume = await docker.Volume("logs-volume", { name: "app-logs", labels: { "com.example.environment": "production", "com.example.backup": "daily" } }); // Run the application container const app = await docker.Container("app", { image: appImage, // Using the custom built image name: "web-app", ports: [{ external: 3000, internal: 3000 }], networks: [{ name: network.name }], volumes: [ { hostPath: logsVolume.name, containerPath: "/app/logs" } ], environment: { REDIS_HOST: "redis", NODE_ENV: "production" }, restart: "always", start: true }); // Output the URL export const url = `http://localhost:3000`; ``` -------------------------------- ### Create a basic Hypervisor Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/backup-gateway/hypervisor.md Initializes a new Hypervisor with essential connection details, KMS encryption, and initial tags. ```ts import AWS from "alchemy/aws/control"; const hypervisor = await AWS.BackupGateway.Hypervisor("myHypervisor", { host: "hypervisor.example.com", username: "admin", password: "securePassword123", kmsKeyArn: "arn:aws:kms:us-west-2:123456789012:key/abcd1234-a123-456a-a12b-a123b4cd56ef", tags: [ { Key: "Environment", Value: "Production" }, { Key: "Department", Value: "IT" } ] }); ``` -------------------------------- ### Install TanStack Store Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy/templates/tanstack-start/README.md Install the TanStack Store package. ```bash bun install @tanstack/store ``` -------------------------------- ### Create a basic QBusiness DataSource Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/aws-control/qbusiness/data-source.md Initializes a minimal DataSource with required IndexId and Configuration properties. ```ts import AWS from "alchemy/aws/control"; const basicDataSource = await AWS.QBusiness.DataSource("basicDataSource", { IndexId: "qbusiness-index-123", Configuration: { dataSourceType: "S3", dataSourceUri: "s3://my-data-bucket/data/" }, DisplayName: "Basic DataSource" }); ``` -------------------------------- ### Install Alchemy dependencies Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/guides/prisma-postgres.md Install the required alchemy package using bun. ```bash bun i alchemy ``` -------------------------------- ### Create a basic project Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/prisma-postgres/project.md Initializes a new project with default settings using the Project constructor. ```ts import { Project } from "alchemy/prisma-postgres"; const project = await Project("my-app"); console.log(`Project ID: ${project.id}`); console.log(`Project Name: ${project.name}`); console.log(`Workspace: ${project.workspace.name}`); ``` -------------------------------- ### Install Bun Source: https://github.com/alchemy-run/alchemy/blob/main/CONTRIBUTING.md Installs the Bun JavaScript runtime. This is a prerequisite for setting up the project. ```sh curl -fsSL https://bun.sh/install | bash ``` -------------------------------- ### Create Database and Connection String Source: https://github.com/alchemy-run/alchemy/blob/main/alchemy-web/src/content/docs/providers/prisma-postgres/database.md This comprehensive example shows how to provision a database and then generate an unencrypted connection string for application use. Ensure both Project, Database, and Connection resources are imported. ```typescript import { Project, Database, Connection } from "alchemy/prisma-postgres"; const project = await Project("my-app"); const database = await Database("production", { project: project, region: "us-east-1" }); const connection = await Connection("app-connection", { database: database, }); console.log(`Connection string available at: ${connection.connectionString.unencrypted}`); ```