Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/content/docs/hyperdrive/examples/prisma-postgres.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
type: example
summary: Connect Hyperdrive to a Prisma Postgres database.
pcx_content_type: example
title: Connect to Prisma Postgres
sidebar:
order: 9
description: Connect Hyperdrive to a Prisma Postgres database.
---

import { Render } from "~/components";

This example shows you how to connect Hyperdrive to a [Prisma](https://www.prisma.io/postgres) Postgres database. Prisma Postgres provides global-first and serverless-ready Postgres databases.

## 1. Allow Hyperdrive access

You can connect Hyperdrive to any existing pgEdge database with the default user and password provided by pgEdge.

### pgEdge dashboard

To retrieve your connection string from the pgEdge dashboard:

1. Go to the [**pgEdge dashboard**](https://app.pgedge.com) and select the database you wish to connect to.
2. From the **Connect to your database** section, note down the connection string (starting with `postgres://app@...`) from the **Connection String** text box.

## 2. Create a database configuration

<Render file="create-hyperdrive-config" />
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
---
pcx_content_type: configuration
title: API
title: Programmatic execution
sidebar:
order: 2
order: 4
head: []
description: A set of programmatic APIs that can be integrated with local
Cloudflare Workers-related workflows.
---

import { Render, TabItem, Tabs, Type, MetaInfo, WranglerConfig } from "~/components";
import {
Render,
TabItem,
Tabs,
Type,
MetaInfo,
WranglerConfig,
} from "~/components";

Programmatic execution can be useful to automate testing of Workers projects in continuous testing environments. In these scenarios, you need a way
to access the underlying server, emulations or bindings of Cloudflare Workers which are usually present when developing with the Wrangler CLI.

Wrangler offers APIs to programmatically interact with your Cloudflare Workers.

Expand Down Expand Up @@ -340,8 +350,6 @@ The bindings supported by `getPlatformProxy` are:

For example, you might have the following file read by `getPlatformProxy`.



<WranglerConfig>

```toml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pcx_content_type: configuration
title: Bundling
head: []
description: Review Wrangler's default bundling.
sidebar:
order: 2
---

By default, Wrangler bundles your Worker code using [`esbuild`](https://esbuild.github.io/). This means that Wrangler has built-in support for importing modules from [npm](https://www.npmjs.com/) defined in your `package.json`. To review the exact code that Wrangler will upload to Cloudflare, run `npx wrangler deploy --dry-run --outdir dist`, which will show your Worker code after Wrangler's bundling.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ pcx_content_type: configuration
title: Custom builds
head: []
description: Customize how your code is compiled, before being processed by Wrangler.

sidebar:
order: 1
---

import { Render, Type, MetaInfo, WranglerConfig } from "~/components"
import { Render, Type, MetaInfo, WranglerConfig } from "~/components";

Custom builds are a way for you to customize how your code is compiled, before being processed by Wrangler.

Expand All @@ -19,21 +20,17 @@ With the release of Wrangler v2, it is no longer necessary to use custom builds

Custom builds are configured by adding a `[build]` section in your `wrangler.toml / wrangler.json` file, and using the following options for configuring your custom build.

- `command` <Type text="string" /> <MetaInfo text="optional" />

- The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. This command will be run as part of `wrangler dev` and `npx wrangler deploy`.

* `command` <Type text="string" /> <MetaInfo text="optional" />

* The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. This command will be run as part of `wrangler dev` and `npx wrangler deploy`.

* `cwd` <Type text="string" /> <MetaInfo text="optional" />

* The directory in which the command is executed.

* `watch_dir` <Type text="string | string\[]" /> <MetaInfo text="optional" />
- `cwd` <Type text="string" /> <MetaInfo text="optional" />

* The directory to watch for changes while using `wrangler dev`. Defaults to the current working directory.
- The directory in which the command is executed.

- `watch_dir` <Type text="string | string\[]" /> <MetaInfo text="optional" />

- The directory to watch for changes while using `wrangler dev`. Defaults to the current working directory.

Example:

Expand Down
16 changes: 16 additions & 0 deletions src/content/docs/wrangler/builds/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Build outputs
pcx_content_type: how-to
head:
- tag: title
content: Build outputs
sidebar:
group:
hideIndex: true
order: 4
description: Customize how your code is compiled or bundled by Wrangler.
---

import { DirectoryListing } from "~/components";

<DirectoryListing />
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
---
pcx_content_type: reference
title: Commands
title: CLI Commands
sidebar:
order: 2
head:
- tag: title
content: Commands - Wrangler
content: CLI Commands - Wrangler
description: Create, develop, and deploy your Cloudflare Workers with Wrangler commands.
---

import { TabItem, Tabs, Render, Type, MetaInfo, WranglerConfig } from "~/components";
import {
TabItem,
Tabs,
Render,
Type,
MetaInfo,
WranglerConfig,
} from "~/components";

Wrangler offers a number of commands to manage your Cloudflare Workers.

Expand Down Expand Up @@ -1841,6 +1850,7 @@ wrangler cert upload certificate-authority --ca-cert <PATH> [OPTIONS]
```

- `--ca-cert` <Type text="string" /> <MetaInfo text="required" />

- A path to the Certificate Authority (CA) chain certificate to upload.

- `--name` <Type text="string" /> <MetaInfo text="optional" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
pcx_content_type: configuration
title: Configuration
title: Configuration file
sidebar:
order: 1
head:
- tag: title
content: Configuration - Wrangler
Expand Down Expand Up @@ -412,7 +414,7 @@ watch_dir = "build_watch_dir"

You can impose limits on your Worker's behavior at runtime. Limits are only supported for the [Standard Usage Model](/workers/platform/pricing/#example-pricing-standard-usage-model). Limits are only enforced when deployed to Cloudflare's network, not in local development. The CPU limit can be set to a maximum of 30,000 milliseconds (30 seconds).

<Render file="isolate-cpu-flexibility" /> <br />
<Render file="isolate-cpu-flexibility" product="workers" /> <br />

- `cpu_ms` <Type text="number" /> <MetaInfo text="optional" />

Expand Down Expand Up @@ -631,8 +633,7 @@ deleted_classes = ["DeprecatedClass"] # Array of deleted class names

Example:

<Render file="envvar-example" />

<Render file="envvar-example" product="workers" />
### Hyperdrive

[Hyperdrive](/hyperdrive/) bindings allow you to interact with and query any Postgres database from within a Worker.
Expand Down Expand Up @@ -1104,7 +1105,7 @@ local_protocol = "http"

[Secrets](/workers/configuration/secrets/) are a type of binding that allow you to [attach encrypted text values](/workers/wrangler/commands/#secret) to your Worker.

<Render file="secrets-in-dev" />
<Render file="secrets-in-dev" product="workers" />

## Module Aliasing

Expand Down Expand Up @@ -1198,7 +1199,7 @@ upload_source_maps = true

## Workers Sites

<Render file="workers_sites" />
<Render file="workers_sites" product="workers" />

[Workers Sites](/workers/configuration/sites/) allows you to host static websites, or dynamic websites using frameworks like Vue or React, on Workers.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ title: Environments
head: []
description: Deploy the same Worker application with different configuration for
each environment.
sidebar:
order: 3
---

import { WranglerConfig } from "~/components";
Expand Down Expand Up @@ -61,8 +63,6 @@ After you have configured your environment, run `npx wrangler deploy` in your Wo

Review the following example Wrangler file:



<WranglerConfig>

```toml
Expand Down Expand Up @@ -95,8 +95,6 @@ You may assign environment-specific [secrets](/workers/configuration/secrets/) b

The following Wrangler file adds two environments, `[env.staging]` and `[env.production]`, to the Wrangler file. If you are deploying to a [Custom Domain](/workers/configuration/routing/custom-domains/) or [route](/workers/configuration/routing/routes/), you must provide a [`route` or `routes` key](/workers/wrangler/configuration/) for each environment.



<WranglerConfig>

```toml
Expand Down Expand Up @@ -168,8 +166,6 @@ if (ENVIRONMENT === "staging") {

To deploy your code to your `*.workers.dev` subdomain, include `workers_dev = true` in the desired environment. Your Wrangler file may look like this:



<WranglerConfig>

```toml
Expand Down
18 changes: 18 additions & 0 deletions src/content/docs/wrangler/configuration/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Configuration
pcx_content_type: how-to
head:
- tag: title
content: Configuration
sidebar:
group:
hideIndex: true
order: 3
description: Configure Wrangler to customize the
development and deployment setup for your Worker project and other Developer
Platform products.
---

import { DirectoryListing } from "~/components";

<DirectoryListing />
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ pcx_content_type: configuration
title: System environment variables
head: []
description: Local environment variables that can change Wrangler's behavior.

sidebar:
order: 2
---

import { Render, Type, MetaInfo } from "~/components"
import { Render, Type, MetaInfo } from "~/components";

System environment variables are local environment variables that can change Wrangler's behavior. There are three ways to set system environment variables:

Expand All @@ -25,47 +26,41 @@ To set different system environment variables for each environment, create files

Wrangler supports the following environment variables:

- `CLOUDFLARE_ACCOUNT_ID` <Type text="string" /> <MetaInfo text="optional" />

- The [account ID](/fundamentals/setup/find-account-and-zone-ids/) for the Workers related account.

* `CLOUDFLARE_ACCOUNT_ID` <Type text="string" /> <MetaInfo text="optional" />

* The [account ID](/fundamentals/setup/find-account-and-zone-ids/) for the Workers related account.

* `CLOUDFLARE_API_TOKEN` <Type text="string" /> <MetaInfo text="optional" />

* The [API token](/fundamentals/api/get-started/create-token/) for your Cloudflare account, can be used for authentication for situations like CI/CD, and other automation.

* `CLOUDFLARE_API_KEY` <Type text="string" /> <MetaInfo text="optional" />

* The API key for your Cloudflare account, usually used for older authentication method with `CLOUDFLARE_EMAIL=`.

* `CLOUDFLARE_EMAIL` <Type text="string" /> <MetaInfo text="optional" />
- `CLOUDFLARE_API_TOKEN` <Type text="string" /> <MetaInfo text="optional" />

* The email address associated with your Cloudflare account, usually used for older authentication method with `CLOUDFLARE_API_KEY=`.
- The [API token](/fundamentals/api/get-started/create-token/) for your Cloudflare account, can be used for authentication for situations like CI/CD, and other automation.

* `WRANGLER_SEND_METRICS` <Type text="string" /> <MetaInfo text="optional" />
- `CLOUDFLARE_API_KEY` <Type text="string" /> <MetaInfo text="optional" />

* Options for this are `true` and `false`. Defaults to `true`. Controls whether Wrangler can send anonymous usage data to Cloudflare for this project. You can learn more about this in our [data policy](https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/telemetry.md).
- The API key for your Cloudflare account, usually used for older authentication method with `CLOUDFLARE_EMAIL=`.

* `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING_NAME>`<Type text="string" /> <MetaInfo text="optional" />
- `CLOUDFLARE_EMAIL` <Type text="string" /> <MetaInfo text="optional" />

* The [local connection string](/hyperdrive/configuration/local-development/) for your database to use in local development with [Hyperdrive](/hyperdrive/). For example, if the binding for your Hyperdrive is named `PROD_DB`, this would be `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_PROD_DB="postgres://user:[email protected]:5432/testdb"`. Each Hyperdrive is uniquely distinguished by the binding name.
- The email address associated with your Cloudflare account, usually used for older authentication method with `CLOUDFLARE_API_KEY=`.

* `CLOUDFLARE_API_BASE_URL` <Type text="string" /> <MetaInfo text="optional" />
- `WRANGLER_SEND_METRICS` <Type text="string" /> <MetaInfo text="optional" />

* The default value is `"https://api.cloudflare.com/client/v4"`.
- Options for this are `true` and `false`. Defaults to `true`. Controls whether Wrangler can send anonymous usage data to Cloudflare for this project. You can learn more about this in our [data policy](https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/telemetry.md).

* `WRANGLER_LOG` <Type text="string" /> <MetaInfo text="optional" />
- `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING_NAME>`<Type text="string" /> <MetaInfo text="optional" />

* Options for Logging levels are `"none"`, `"error"`, `"warn"`, `"info"`, `"log"` and `"debug"`. Levels are case-insensitive and default to `"log"`. If an invalid level is specified, Wrangler will fallback to the default. Logs can include requests to Cloudflare's API, any usage data being collected, and more verbose error logs.
- The [local connection string](/hyperdrive/configuration/local-development/) for your database to use in local development with [Hyperdrive](/hyperdrive/). For example, if the binding for your Hyperdrive is named `PROD_DB`, this would be `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_PROD_DB="postgres://user:[email protected]:5432/testdb"`. Each Hyperdrive is uniquely distinguished by the binding name.

* `FORCE_COLOR` <Type text="string" /> <MetaInfo text="optional" />
- `CLOUDFLARE_API_BASE_URL` <Type text="string" /> <MetaInfo text="optional" />

* By setting this to `0`, you can disable Wrangler's colorised output, which makes it easier to read with some terminal setups. For example, `FORCE_COLOR=0`.
- The default value is `"https://api.cloudflare.com/client/v4"`.

- `WRANGLER_LOG` <Type text="string" /> <MetaInfo text="optional" />

- Options for Logging levels are `"none"`, `"error"`, `"warn"`, `"info"`, `"log"` and `"debug"`. Levels are case-insensitive and default to `"log"`. If an invalid level is specified, Wrangler will fallback to the default. Logs can include requests to Cloudflare's API, any usage data being collected, and more verbose error logs.

- `FORCE_COLOR` <Type text="string" /> <MetaInfo text="optional" />

- By setting this to `0`, you can disable Wrangler's colorised output, which makes it easier to read with some terminal setups. For example, `FORCE_COLOR=0`.

## Example `.env` file

Expand All @@ -84,8 +79,8 @@ WRANGLER_LOG=debug

The following variables are deprecated. Use the new variables listed above to prevent any issues or unwanted messaging.

* `CF_ACCOUNT_ID`
* `CF_API_TOKEN`
* `CF_API_KEY`
* `CF_EMAIL`
* `CF_API_BASE_URL`
- `CF_ACCOUNT_ID`
- `CF_API_TOKEN`
- `CF_API_KEY`
- `CF_EMAIL`
- `CF_API_BASE_URL`
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
title: Wrangler
pcx_content_type: navigation
pcx_content_type: overview
sidebar:
order: 15
head:
- tag: title
content: Wrangler
order: 1
---

import { DirectoryListing } from "~/components";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Wrangler is installed locally into each of your projects. This allows you and yo

To install Wrangler within your Worker project, run:

<Render file="install_wrangler" />
<Render file="install_wrangler" product="workers" />

Since Cloudflare recommends installing Wrangler locally in your project (rather than globally), the way to run Wrangler will depend on your specific setup and package manager. Refer to [How to run Wrangler commands](/workers/wrangler/commands/#how-to-run-wrangler-commands) for more information.

Expand Down
Loading
Loading