### Sphinx quickstart configuration Source: https://developers.cloudflare.com/pages/framework-guides/deploy-a-sphinx-site/index Example responses for the sphinx-quickstart interactive setup. ```sh Separate source and build directories (y/n) [n]: Y Project name: Author name(s): Project release []: Project language [en]: ``` -------------------------------- ### Get started template structure Source: https://developers.cloudflare.com/style-guide/documentation-content-strategy/content-types/get-started/index A template for structuring 'Get started' documentation, including frontmatter and required sections. ```plaintext --- weight: xx pcx_content_type: get-started description: Set up for the first time by . Requires . products: - product-a - product-b - product-c --- # Get started Description ## Before you begin All the things you need to do before you start configuring your product, both within Cloudflare and outside. ## 1. Step description ## 2. Steps until you get to activation --- ## Next steps Point to more complex setup options. ``` -------------------------------- ### Clone and run LangChain example Source: https://developers.cloudflare.com/workers/languages/python/packages/langchain/index Commands to clone the example repository and start the development server using uv. ```bash git clone https://github.com/cloudflare/python-workers-examples cd 05-langchain uv run pywrangler dev ``` -------------------------------- ### Install dependencies and start development server Source: https://developers.cloudflare.com/agents/getting-started/quick-start/index Commands to navigate to the project directory, install dependencies, and launch the development environment. ```sh cd agents-starter npm install npm run dev ``` -------------------------------- ### Clone and run the FastAPI example Source: https://developers.cloudflare.com/workers/languages/python/packages/fastapi/index Commands to clone the example repository and start the development server. ```bash git clone https://github.com/cloudflare/python-workers-examples cd python-workers-examples/03-fastapi uv run pywrangler dev ``` -------------------------------- ### Project scaffolding output Source: https://developers.cloudflare.com/pages/framework-guides/deploy-a-vite3-project/index Example output showing the interactive project setup and subsequent installation commands. ```shell ✔ Project name: … vite-on-pages ✔ Select a framework: › vue ✔ Select a variant: › vue Scaffolding project in ~/src/vite-on-pages... Done. Now run: cd vite-on-pages npm install npm run dev ``` -------------------------------- ### startProcess() Implementation Source: https://developers.cloudflare.com/sandbox/api/commands/index Examples of starting background processes with custom environments and stdin input. ```js const server = await sandbox.startProcess("python -m http.server 8000"); console.log("Started with PID:", server.pid); // With custom environment const app = await sandbox.startProcess("node app.js", { cwd: "/workspace/my-app", env: { NODE_ENV: "production", PORT: "3000" }, }); // Start process with stdin input (useful for interactive applications) const interactive = await sandbox.startProcess("python interactive_app.py", { stdin: "initial_config\nstart_mode\n", }); ``` ```ts const server = await sandbox.startProcess('python -m http.server 8000'); console.log('Started with PID:', server.pid); // With custom environment const app = await sandbox.startProcess('node app.js', { cwd: '/workspace/my-app', env: { NODE_ENV: 'production', PORT: '3000' } }); // Start process with stdin input (useful for interactive applications) const interactive = await sandbox.startProcess('python interactive_app.py', { stdin: 'initial_config\nstart_mode\n' }); ``` -------------------------------- ### Install and Setup Python boto3 Source: https://developers.cloudflare.com/r2/get-started/s3/index Commands to install the boto3 library and prepare a local test file. ```sh pip install boto3 ``` ```sh echo 'Hello, R2!' > myfile.txt ``` -------------------------------- ### Clone and install custom headers template Source: https://developers.cloudflare.com/pages/how-to/add-custom-http-headers/index Use these commands to clone the example repository and install dependencies. ```sh git clone https://github.com/cloudflare/custom-headers-example cd custom-headers-example npm install ``` -------------------------------- ### Install and start yubikey-agent Source: https://developers.cloudflare.com/cloudflare-one/access-controls/access-settings/independent-mfa/index Installs and initializes the yubikey-agent service on macOS. ```bash brew install yubikey-agent brew services start yubikey-agent ``` -------------------------------- ### Full Implementation Example Source: https://developers.cloudflare.com/resources/index A complete example showing the setup of a Workers script, zone retrieval, route creation, and record definition. ```javascript "use strict"; const pulumi = require("@pulumi/pulumi"); const cloudflare = require("@pulumi/cloudflare"); const config = new pulumi.Config(); const accountId = config.require("accountId"); const domain = config.require("domain"); const content = `export default { async fetch(request) { const options = { headers: { 'content-type': 'text/plain' } }; return new Response("Hello World!", options); }, };`; const worker = new cloudflare.WorkersScript("hello-world-worker", { accountId: accountId, name: "hello-world-worker", content: content, module: true, // ES6 module }); const zone = cloudflare.getZone({ accountId: accountId, name: domain, }); const zoneId = zone.then((z) => z.zoneId); const route = new cloudflare.WorkersRoute("hello-world-route", { zoneId: zoneId, pattern: "hello-world." + domain, scriptName: worker.name, }); const record = new ``` -------------------------------- ### Initialize lib.rs Source: https://developers.cloudflare.com/resources/index Basic setup for the Worker entry point in lib.rs. ```rs use worker::*; mod utils; #[event(fetch)] pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result { // Optionally, get more helpful error messages written to the console in the case of a panic. utils::set_panic_hook(); let router = Router::new(); router .get("/", |_, _| Response::ok("Hello from Workers!")) .run(req, env) .await } ``` -------------------------------- ### Installation output Source: https://developers.cloudflare.com/resources/index The expected output after installing the required dependencies. ```text Requirement already satisfied: requests in ./venv/lib/python3.12/site-packages (2.31.0) Requirement already satisfied: python-dotenv in ./venv/lib/python3.12/site-packages (1.0.1) Requirement already satisfied: charset-normalizer<4,>=2 in ./venv/lib/python3.12/site-packages (from requests) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.12/site-packages (from requests) (3.6) Requirement already satisfied: urllib3<3,>=1.21.1 in ./venv/lib/python3.12/site-packages (from requests) (2.1.0) Requirement already satisfied: certifi>=2017.4.17 in ./venv/lib/python3.12/site-packages (from requests) (2023.11.17) ``` -------------------------------- ### PKCS#11 tool output example Source: https://developers.cloudflare.com/resources/index Example output showing RSA key objects retrieved from the token. ```txt Using slot 0 with a present token (0x1d622495) Private Key Object; RSA label: rsa-privkey ID: 105013281578de42ea45f5bfac46d302fb006687 Usage: decrypt, sign, unwrap warning: PKCS11 function C_GetAttributeValue(ALWAYS_AUTHENTICATE) failed: rv = CKR_ATTRIBUTE_TYPE_INVALID (0x12) Public Key Object; RSA 2048 bits label: rsa-privkey ID: 105013281578de42ea45f5bfac46d302fb006687 Usage: encrypt, verify, wrap ``` -------------------------------- ### Initialize and Configure Project Source: https://developers.cloudflare.com/cloudflare-one/tutorials/entra-id-risky-users/index Commands to clone the example project and navigate to the directory. ```sh npm create cloudflare@latest risky-users -- --template https://github.com/cloudflare/msft-risky-user-ad-sync ``` ```sh cd risky-users ``` -------------------------------- ### Implement Repository Testing in Cloudflare Sandbox Source: https://developers.cloudflare.com/resources/index This example demonstrates a fetch handler that clones a repository, installs dependencies, and executes tests. It requires the @cloudflare/sandbox package and a configured Durable Object namespace. ```typescript import { parseSSEStream, type Sandbox, type ExecEvent } from '@cloudflare/sandbox'; export { Sandbox } from '@cloudflare/sandbox'; interface Env { Sandbox: DurableObjectNamespace; GITHUB_TOKEN?: string; } export default { async fetch(request: Request, env: Env): Promise { const proxyResponse = await proxyToSandbox(request, env); if (proxyResponse) return proxyResponse; if (request.method !== 'POST') { return new Response('POST { "repoUrl": "https://github.com/owner/repo", "branch": "main" }'); } try { const { repoUrl, branch } = await request.json(); if (!repoUrl) { return Response.json({ error: 'repoUrl required' }, { status: 400 }); } const sandbox = getSandbox(env.Sandbox, `test-${Date.now()}`); try { // Clone repository console.log('Cloning repository...'); let cloneUrl = repoUrl; if (env.GITHUB_TOKEN && cloneUrl.includes('github.com')) { cloneUrl = cloneUrl.replace('https://', `https://${env.GITHUB_TOKEN}@`); } await sandbox.gitCheckout(cloneUrl, { ...(branch && { branch }), depth: 1, targetDir: 'repo' }); console.log('Repository cloned'); // Detect project type const projectType = await detectProjectType(sandbox); console.log(`Detected ${projectType} project`); // Install dependencies const installCmd = getInstallCommand(projectType); if (installCmd) { console.log('Installing dependencies...'); const installStream = await sandbox.execStream(`cd /workspace/repo && ${installCmd}`); let installExitCode = 0; for await (const event of parseSSEStream(installStream)) { if (event.type === 'stdout' || event.type === 'stderr') { console.log(event.data); } else if (event.type === 'complete') { installExitCode = event.exitCode; } } if (installExitCode !== 0) { return Response.json({ success: false, error: 'Install failed', exitCode: installExitCode }); } console.log('Dependencies installed'); } // Run tests console.log('Running tests...'); const testCmd = getTestCommand(projectType); const testStream = await sandbox.execStream(`cd /workspace/repo && ${testCmd}`); let testExitCode = 0; for await (const event of parseSSEStream(testStream)) { if (event.type === 'stdout' || event.type === 'stderr') { console.log(event.data); } else if (event.type === 'complete') { testExitCode = event.exitCode; } } console.log(`Tests completed with exit code ${testExitCode}`); return Response.json({ success: testExitCode === 0, exitCode: testExitCode, projectType, message: testExitCode === 0 ? 'All tests passed' : 'Tests failed' }); } finally { await sandbox.destroy(); } } catch (error: any) { return Response.json({ error: error.message }, { status: 500 }); } }, }; async function detectProjectType(sandbox: any): Promise { try { await sandbox.readFile('/workspace/repo/package.json'); return 'nodejs'; } catch {} try { await sandbox.readFile('/workspace/repo/requirements.txt'); return 'python'; } catch {} try { await sandbox.readFile('/workspace/repo/go.mod'); return 'go'; } catch {} return 'unknown'; } function getInstallCommand(projectType: string): string { switch (projectType) { case 'nodejs': return 'npm install'; case 'python': return 'pip install -r requirements.txt || pip install -e .'; case 'go': return 'go mod download'; default: return ''; } } function getTestCommand(projectType: string): string { switch (projectType) { case 'nodejs': return 'npm test'; case 'python': return 'python -m pytest || python -m unittest discover'; case 'go': return 'go test ./...'; default: return 'echo "Unknown project type"'; } } ``` -------------------------------- ### Schema.org metadata for Queues documentation Source: https://developers.cloudflare.com/queues/get-started/index JSON-LD structured data providing metadata for the getting started guide. ```json {"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/queues/get-started/#page","headline":"Getting started · Cloudflare Queues docs","description":"Create your first Cloudflare Queue, a producer Worker, and a consumer Worker.","url":"https://developers.cloudflare.com/queues/get-started/","inLanguage":"en","image":"https://developers.cloudflare.com/dev-products-preview.png","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}} ``` ```json {"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"/directory/","name":"Directory"}},{"@type":"ListItem","position":2,"item":{"@id":"/queues/","name":"Queues"}},{"@type":"ListItem","position":3,"item":{"@id":"/queues/get-started/","name":"Getting started"}}]} ``` -------------------------------- ### Terraform Plan Output Example Source: https://developers.cloudflare.com/resources/index Example of a Terraform plan showing resources to be created. ```hcl proxiable = (known after apply) + proxied = true + ttl = 1 + type = "A" + value = "192.0.2.1" + zone_id = "1109d899a5ff5fd74bc01e581693685b" } # cloudflare_record.terraform_managed_resource_5e10399a590a45279f09aa8fb1163354 will be created + resource "cloudflare_record" "terraform_managed_resource_5e10399a590a45279f09aa8fb1163354" { + id = (known after apply) + created_on = (known after apply) + domain = "mitigateddos.net" + hostname = (known after apply) + metadata = (known after apply) + modified_on = (known after apply) + name = "www.mitigateddos.net" + proxiable = (known after apply) + proxied = true + ttl = 1 + type = "CNAME" + value = "mitigateddos.net" + zone_id = "1109d899a5ff5fd74bc01e581693685b" } # cloudflare_record.terraform_managed_resource_de1cb74bae184b569bb7f83fefe72248 will be created + resource "cloudflare_record" "terraform_managed_resource_de1cb74bae184b569bb7f83fefe72248" { + id = (known after apply) + created_on = (known after apply) + domain = "mitigateddos.net" + hostname = (known after apply) + metadata = (known after apply) + modified_on = (known after apply) + name = "a123.mitigateddos.net" + proxiable = (known after apply) + proxied = false + ttl = 300 + type = "NS" + value = "rafe.ns.cloudflare.com" + zone_id = "1109d899a5ff5fd74bc01e581693685b" } # cloudflare_record.terraform_managed_resource_5799bb01054843eea726758f935d2aa2 will be created + resource "cloudflare_record" "terraform_managed_resource_5799bb01054843eea726758f935d2aa2" { + id = (known after apply) + created_on = (known after apply) + domain = "mitigateddos.net" + hostname = (known after apply) + metadata = (known after apply) + modified_on = (known after apply) + name = "a123.mitigateddos.net" + proxiable = (known after apply) + proxied = false + ttl = 300 + type = "NS" + value = "terin.ns.cloudflare.com" + zone_id = "1109d899a5ff5fd74bc01e581693685b" } Plan: 4 to add, 0 to change, 0 to destroy. ------------------------------------------------------------------------ Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now. ``` -------------------------------- ### Initialize project and clone examples Source: https://developers.cloudflare.com/workers/languages/python/index Commands to initialize a project via CLI or clone the official examples repository. ```bash uv run pywrangler init ``` ```bash git clone https://github.com/cloudflare/python-workers-examples cd python-workers-examples/01-hello ``` -------------------------------- ### Development Server Output Source: https://developers.cloudflare.com/resources/index Example output showing the local server status and available shortcuts. ```txt ⛅️ wrangler 3.80.2 ------------------- ⎔ Starting local server... [wrangler:inf] Ready on http://localhost:8787 ╭───────────────────────────╮ │ [b] open a browser │ │ [d] open devtools │ │ [l] turn off local mode │ │ [c] clear console │ │ [x] to exit │ ╰───────────────────────────╯ ``` -------------------------------- ### Create Nuxt.js Project Source: https://developers.cloudflare.com/resources/index Initialize a new Nuxt.js project and start the development server. ```shell ``` ```shell cd blog ``` ```shell ``` -------------------------------- ### Install Dependencies Source: https://developers.cloudflare.com/resources/index Commands to install the Cloudflare package for your project. ```sh mvn clean install ``` ```sh dotnet add package Pulumi.Cloudflare ``` -------------------------------- ### container.start() Source: https://developers.cloudflare.com/durable-objects/api/container/index Boots a container with specified environment variables, entrypoint, and network settings. ```APIDOC ## Method: start() ### Description Boots a container. This method does not block until the container is fully started. ### Parameters - **options** (object, optional) - **env** (object) - Environment variables to pass to the container. - **entrypoint** (string[]) - Command to run in the container. - **enableInternet** (boolean) - Whether to enable internet access. ``` -------------------------------- ### Install and Start HTTPD Source: https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/aws-alb-integration/index Commands to install and start the HTTPD daemon on an Amazon Linux 2023 instance. ```bash sudo yum install -y httpd sudo systemctl start httpd ``` -------------------------------- ### Install Dependencies Source: https://developers.cloudflare.com/resources/index Commands to install the required Puppeteer and robots-parser packages. ```shell ``` -------------------------------- ### Get location details response example Source: https://developers.cloudflare.com/api/resources/radar/index Example JSON response for the get location details endpoint. ```json { "result": { "location": { "alpha2": "AF", "confidenceLevel": 5, "continent": "AS", "latitude": "10", "longitude": "10", "name": "Afghanistan", "region": "Middle East", "subregion": "Southern Asia" } }, "success": true } ``` -------------------------------- ### POST /zones Source: https://developers.cloudflare.com/resources/index Creates a new zone with a partial setup type. ```APIDOC ## POST /zones ### Description Creates a new zone in your Cloudflare account with a 'partial' type, which is used for CNAME DNS setups. ### Method POST ### Endpoint /zones ### Request Body - **name** (string) - Required - The domain name to add. - **account** (object) - Required - The account object containing the account ID. - **type** (string) - Required - The setup type, which must be 'partial'. ### Request Example { "name": "example.com", "account": { "id": "YOUR_ACCOUNT_ID" }, "type": "partial" } ``` -------------------------------- ### Wrangler configuration file Source: https://developers.cloudflare.com/resources/index Example wrangler.toml configuration setting the project name. ```jsonc { "$schema": "./node_modules/wrangler/config-schema.json", "name": "worker-to-text" } ``` -------------------------------- ### D1 Database Configuration Output Source: https://developers.cloudflare.com/resources/index Example output showing the database configuration details after creation. ```sh ✅ Successfully created DB 'd1-http-example' in region EEUR Created your new D1 database. [[d1_databases]] binding = "DB" # i.e. available in your Worker on env.DB database_name = "d1-http-example" database_id = "1234567890" ``` -------------------------------- ### Get Flagship App Response Example Source: https://developers.cloudflare.com/api/resources/flagship/index Example JSON response structure for the get app endpoint. ```json { "errors": [ { "message": "message" } ], "messages": [ { "message": "message" } ], "result": { "id": "id", "created_at": "created_at", "name": "name", "updated_at": "updated_at", "updated_by": "updated_by" }, "success": true } ``` -------------------------------- ### Deployment Output Example Source: https://developers.cloudflare.com/workers/tutorials/connect-to-turso-using-workers/index Example output showing successful deployment and binding configuration. ```txt Your worker has access to the following bindings: - Vars: - LIBSQL_DB_URL: "your-url" ... Published worker-turso-ts (0.19 sec) https://worker-turso-ts..workers.dev Current Deployment ID: f9e6b48f-5aac-40bd-8f44-8a40be2212ff ``` -------------------------------- ### Install Cloudflare Pulumi Package Source: https://developers.cloudflare.com/resources/index Commands to install the Cloudflare SDK for different programming environments. ```sh npm install @pulumi/cloudflare ``` ```sh echo "pulumi_cloudflare>=5.38,<6.0.0" >> requirements.txt source venv/bin/activate pip install -r requirements.txt ``` ```sh go get github.com/pulumi/pulumi-cloudflare/sdk/v3/go/cloudflare ``` ```xml com.pulumi cloudflare 5.38.0 ``` ```sh mvn clean install ``` ```sh dotnet add package Pulumi.Cloudflare ``` -------------------------------- ### Initialize Hono Application Source: https://developers.cloudflare.com/resources/index Basic setup for a Hono application to handle incoming requests. ```js import { Hono } from "hono"; const app = new Hono(); // Existing post route... // app.post('/notes', async (c) => { ... ``` -------------------------------- ### Get session details response example Source: https://developers.cloudflare.com/api/resources/browser_rendering/index Example JSON response body for the get session details endpoint. ```json { "sessionId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "closeReason": "closeReason", "closeReasonText": "closeReasonText", "connectionEndTime": 0, "connectionId": "connectionId", "connectionStartTime": 0, "devtoolsFrontendUrl": "devtoolsFrontendUrl", "endTime": 0, "lastUpdated": 0, "startTime": 0, "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ``` -------------------------------- ### Initialize workflows-starter-template Source: https://developers.cloudflare.com/workers/get-started/quickstarts/index Use these commands to scaffold a project demonstrating Cloudflare Workflows. ```bash npm create cloudflare@latest -- --template=cloudflare/templates/workflows-starter-template ``` ```bash yarn create cloudflare --template=cloudflare/templates/workflows-starter-template ``` ```bash pnpm create cloudflare@latest --template=cloudflare/templates/workflows-starter-template ``` -------------------------------- ### API response examples Source: https://developers.cloudflare.com/resources/index Expected JSON output for API requests. ```json { "success": true, "members": [ { "id": 1, "name": "Alice Johnson", "email": "alice@example.com", "joined_date": "2024-01-15" }, { "id": 2, "name": "Bob Smith", "email": "bob@example.com", "joined_date": "2024-02-20" }, { "id": 3, "name": "Carol Williams", "email": "carol@example.com", "joined_date": "2024-03-10" } ] } ``` ```json { "success": true, "message": "Member created successfully", "id": 4 } ``` -------------------------------- ### GET request template and example Source: https://developers.cloudflare.com/style-guide/api-content-strategy/guidelines-for-curl-commands/index Templates and examples for performing GET requests without explicit request method arguments. ```txt curl {full_url_with_placeholders} \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` ```bash curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/firewall/rules \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` -------------------------------- ### Start development server Source: https://developers.cloudflare.com/style-guide/contributions/index Launch the local development server to preview documentation changes. ```bash pnpm run dev ``` -------------------------------- ### Wrangler configuration for D1 Source: https://developers.cloudflare.com/resources/index Example configuration for binding a D1 database to a Worker project. ```toml name = "d1-comments-api" main = "src/index.ts" compatibility_date = "$today" [[d1_databases]] binding = "DB" # available in your Worker on env.DB database_name = "d1-comments-api" database_id = "" ``` -------------------------------- ### Get destination address response example Source: https://developers.cloudflare.com/api/resources/email_routing/index Example JSON response structure returned by the get destination address endpoint. ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "ea95132c15732412d22c1476fa83f27a", "created": "2014-01-02T02:20:00Z", "email": "user@example.com", "modified": "2014-01-02T02:20:00Z", "tag": "ea95132c15732412d22c1476fa83f27a", "verified": "2014-01-02T02:20:00Z" } } ``` -------------------------------- ### KV Namespace Creation Output Source: https://developers.cloudflare.com/resources/index Example output showing the generated namespace IDs to be added to the configuration. ```text 🌀 Creating namespace with title "web-crawler-crawler-links" ✨ Success! Add the following to your configuration file in your kv_namespaces array: [[kv_namespaces]] binding = "crawler_links" id = "" 🌀 Creating namespace with title "web-crawler-crawler-screenshots" ✨ Success! Add the following to your configuration file in your kv_namespaces array: [[kv_namespaces]] binding = "crawler_screenshots" id = "" ``` -------------------------------- ### Install dependencies Source: https://developers.cloudflare.com/style-guide/contributions/index Install project dependencies using pnpm before starting the development server. ```bash pnpm install ``` -------------------------------- ### Run Sphinx quickstart Source: https://developers.cloudflare.com/pages/framework-guides/deploy-a-sphinx-site/index Initializes a new Sphinx project template. ```sh sphinx-quickstart ``` -------------------------------- ### Example _headers File Configuration Source: https://developers.cloudflare.com/pages/configuration/headers/index A sample _headers file demonstrating comments, path-based rules, and absolute URL matching. ```txt # This is a comment /secure/page X-Frame-Options: DENY X-Content-Type-Options: nosniff Referrer-Policy: no-referrer /static/* Access-Control-Allow-Origin: * X-Robots-Tag: nosnippet https://myproject.pages.dev/* X-Robots-Tag: noindex ``` -------------------------------- ### Get domain API response structure Source: https://developers.cloudflare.com/api/resources/registrar/index Example of the JSON response returned by the Get domain endpoint. ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": {}, "success": true } ``` -------------------------------- ### Initialize astro-blog-starter-template Source: https://developers.cloudflare.com/workers/get-started/quickstarts/index Commands to create a new project using the astro-blog-starter-template. ```bash npm create cloudflare@latest -- --template=cloudflare/templates/astro-blog-starter-template ``` ```bash yarn create cloudflare --template=cloudflare/templates/astro-blog-starter-template ``` ```bash pnpm create cloudflare@latest --template=cloudflare/templates/astro-blog-starter-template ``` -------------------------------- ### Initialize d1-starter-sessions-api-template Source: https://developers.cloudflare.com/workers/get-started/quickstarts/index Create a new project using the d1-starter-sessions-api-template. ```bash npm create cloudflare@latest -- --template=cloudflare/templates/d1-starter-sessions-api-template ``` ```bash yarn create cloudflare --template=cloudflare/templates/d1-starter-sessions-api-template ``` ```bash pnpm create cloudflare@latest --template=cloudflare/templates/d1-starter-sessions-api-template ``` -------------------------------- ### Wrangler configuration for D1 Source: https://developers.cloudflare.com/resources/index Example configuration for wrangler.toml or wrangler.jsonc to bind the D1 database to the Worker. ```jsonc { "$schema": "./node_modules/wrangler/config-schema.json", "name": "prisma-d1-example", "main": "src/index.ts", "compatibility_date": "$today", "compatibility_flags": [ "nodejs_compat" ], "observability": { "enabled": true }, "d1_databases": [ { "binding": "DB", // i.e. available in your Worker on env.DB "database_name": "prisma-demo-db", "database_id": "" } ] } ``` -------------------------------- ### Initial lib.rs setup Source: https://developers.cloudflare.com/workers/tutorials/generate-youtube-thumbnails-with-workers-and-images/index Basic structure for the Worker's lib.rs file with a router. ```rs use worker::*; mod utils; #[event(fetch)] pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result { // Optionally, get more helpful error messages written to the console in the case of a panic. utils::set_panic_hook(); let router = Router::new(); router .get("/", |_, _| Response::ok("Hello from Workers!")) .run(req, env) .await } ``` -------------------------------- ### Define a Workers Script with Pulumi Source: https://developers.cloudflare.com/resources/index Examples of configuring a WorkersScript resource to deploy a basic Hello World worker. ```java package myproject; import com.pulumi.Pulumi; import com.pulumi.cloudflare.WorkersScript; import com.pulumi.cloudflare.WorkersScriptArgs; import com.pulumi.core.Output; public class App { public static void main(String[] args) { Pulumi.run(ctx -> { var content = """ export default { async fetch(request) { const options = { headers: { 'content-type': 'text/plain' } }; return new Response("Hello World!", options); }, }; """; var accountId = ctx.config().require("accountId"); var domain = ctx.config().require("domain"); var worker = new WorkersScript("hello-world-worker", WorkersScriptArgs.builder() .accountId(accountId) .name("hello-world-worker") .content(content) .module(true) .build()); return; }); } } ``` ```csharp using Pulumi; using Cloudflare = Pulumi.Cloudflare; return await Deployment.RunAsync(() => { var config = new Config(); var accountId = config.Require("accountId"); var domain = config.Require("domain"); var content = @" export default { async fetch(request) { const options = { headers: { 'content-type': 'text/plain' } }; return new Response(""Hello World!"", options); }, }; "; var worker = new Cloudflare.WorkersScript("hello-world-worker", new() { AccountId = accountId, Name = "hello-world-worker", Content = content, Module = true }); return; }); ``` ```yaml name: serverless-cloudflare runtime: yaml resources: worker: type: cloudflare:WorkersScript properties: accountId: "${accountId}" name: "hello-world-worker" content: | export default { async fetch(request) { const options = { headers: { 'content-type': 'text/plain' } }; return new Response("Hello World!", options); }, }; module: true ```