Skip to content

Commit

Permalink
chore(main): release 3.20.0 (#867)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: JakeChampion <[email protected]>
  • Loading branch information
github-actions[bot] and JakeChampion authored Aug 8, 2024
1 parent 6e81d41 commit 8b4cc26
Show file tree
Hide file tree
Showing 698 changed files with 25,770 additions and 79 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 3.20.0 (2024-08-08)

### Added

* Add new CLI name of `js-compute` which matches the published package name `@fastly/js-compute` ([#869](https://github.com/fastly/js-compute-runtime/issues/869)) ([60d1d20](https://github.com/fastly/js-compute-runtime/commit/60d1d2067d846aa15a76820e666004cf56d1df99))

### Fixed

* core-cache headers case ([#889](https://github.com/fastly/js-compute-runtime/issues/889)) ([3f2db5c](https://github.com/fastly/js-compute-runtime/commit/3f2db5c466151efddf1731c6be080c2a2875a43d))
* ensure we throw an error if FastlyBody.prototype.read is called with a value which is not coercible to a finite positive integer ([#877](https://github.com/fastly/js-compute-runtime/issues/877)) ([1633e02](https://github.com/fastly/js-compute-runtime/commit/1633e025d92be3a1f8b0616685b48e27dc913841))
* perf: Use wasm-opt -O3 when making a release build ([#870](https://github.com/fastly/js-compute-runtime/issues/870)) ([dd91fa5](https://github.com/fastly/js-compute-runtime/commit/dd91fa506b74487b70dc5bec510e89de95e1c569))
* When constructing an EdgeRateLimiter, retrieve the PenaltyBox instance's name using PenaltyBox::get\_name ([#866](https://github.com/fastly/js-compute-runtime/issues/866)) ([9222f1d](https://github.com/fastly/js-compute-runtime/commit/9222f1d16a9c17b080be575affffbb83c461dd81))

### Changed

* only time the fetch event when debug logging is enabled ([#873](https://github.com/fastly/js-compute-runtime/issues/873)) ([e4ddf8a](https://github.com/fastly/js-compute-runtime/commit/e4ddf8ac3c78bea753e8d9418715d1e703e7e7bc))
* re-order the http methods so the most often requested is first and the least requested is last ([#874](https://github.com/fastly/js-compute-runtime/issues/874)) ([6af7626](https://github.com/fastly/js-compute-runtime/commit/6af7626085af62a14520f14f69a0e64a515fd5ef))
* Use MOZ\_ASSERT instead of MOZ\_RELEASE\_ASSERT as these methods are already guarded correctly where they are being called ([#876](https://github.com/fastly/js-compute-runtime/issues/876)) ([f089616](https://github.com/fastly/js-compute-runtime/commit/f089616e8febc783cc96363f5ce65fc6f1acafb1))

## 3.19.0 (2024-07-29)

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
import {Fiddle} from '@site/src/components/fiddle';

# `Backend()`

The **`Backend` constructor** lets you dynamically create new [Fastly Backends](https://developer.fastly.com/reference/api/services/backend/) for your Fastly Compute service.

Dynamically creating new [Fastly Backends](https://developer.fastly.com/reference/api/services/backend/) is disabled by default for Fastly Services. Please contact [Fastly Support](https://support.fastly.com/hc/requests/new?ticket_form_id=360000269711) to request the feature be enabled on the Fastly Services which require Dynamic Backends.

By default, Dynamic Backends are disabled within a JavaScript application as it can be a potential avenue for third-party JavaScript code to send requests, potentially including sensitive/secret data, off to destinations that the JavaScript project was not intending, which could be a security issue.

To enable Dynamic Backends the application will need to explicitly allow Dynamic Backends via:

```js
import { allowDynamicBackends } from "fastly:experimental";
allowDynamicBackends(true);
```

**Note**: Backend constructors can only be used when processing requests, not during build-time initialization.

## Syntax

```js
new Backend(backendConfiguration)
```

> **Note:** `Backend()` can only be constructed with `new`. Attempting to call it without `new` throws a [`TypeError`](../../globals/TypeError/TypeError.mdx).
### Parameters

- `backendConfiguration`

- : An Object which contains all the configuration options to apply to the newly created Backend.

- `name` _: string_
- The name of the backend.
- The name has to be between 1 and 254 characters inclusive.
- The name can be whatever you would like, as long as it does not match the name of any of the static service backends nor match any other dynamic backends built during a single execution of the application.
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is not valid. I.E. The value is null, undefined, an empty string or a string with more than 254 characters.
- `target` _: string_
- A hostname, IPv4, or IPv6 address for the backend as well as an optional port.
- The target has to be at-least 1 character.
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is not valid. I.E. Is null, undefined, an empty string, not a valid IP address or host, or is the string `::`
- `hostOverride` _: string_ _**optional**_
- If set, will force the HTTP Host header on connections to this backend to be the supplied value.
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
- `connectTimeout` _: number_ _**optional**_
- Maximum duration in milliseconds to wait for a connection to this backend to be established.
- If exceeded, the connection is aborted and a 503 response will be presented instead.
- Throws a [`RangeError`](../../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
- `firstByteTimeout` _: number_ _**optional**_
- Maximum duration in milliseconds to wait for the server response to begin after a TCP connection is established and the request has been sent.
- If exceeded, the connection is aborted and a 503 response will be presented instead.
- Throws a [`RangeError`](../../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
- `betweenBytesTimeout` _: number_ _**optional**_
- Maximum duration in milliseconds that Fastly will wait while receiving no data on a download from a backend.
- If exceeded, the response received so far will be considered complete and the fetch will end.
- Throws a [`RangeError`](../../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
- `useSSL` _: boolean_ _**optional**_
- Whether or not to require TLS for connections to this backend.
- `dontPool` _: boolean_ _**optional**_
- Determine whether or not connections to the same backend should be pooled across different sessions.
- Fastly considers two backends “the same” if they're registered with the same name and the exact same settings.
- In those cases, when pooling is enabled, if Session 1 opens a connection to this backend it will be left open, and can be re-used by Session 2.
- This can help improve backend latency, by removing the need for the initial network / TLS handshake(s).
- By default, pooling is enabled for dynamic backends.
- `tlsMinVersion` _: 1 | 1.1 | 1.2 | 1.3_ _**optional**_
- Minimum allowed TLS version on SSL connections to this backend.
- If the backend server is not able to negotiate a connection meeting this constraint, a 503 response will be presented instead.
- Throws a [`RangeError`](../../globals/RangeError/RangeError.mdx) if the value is not 1, 1.1, 1.2, or 1.3
- `tlsMaxVersion` _: 1 | 1.1 | 1.2 | 1.3_ _**optional**_
- Maximum allowed TLS version on SSL connections to this backend.
- If the backend server is not able to negotiate a connection meeting this constraint, a 503 response will be presented instead.
- Throws a [`RangeError`](../../globals/RangeError/RangeError.mdx) if the value is not 1, 1.1, 1.2, or 1.3
- `certificateHostname` _: string_ _**optional**_
- Define the hostname that the server certificate should declare.
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
- `caCertificate` _: string_ _**optional**_
- The CA certificate to use when checking the validity of the backend.
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
- `ciphers` _: string_ _**optional**_
- List of OpenSSL ciphers to support for connections to this origin.
- If the backend server is not able to negotiate a connection meeting this constraint, a 503 response will be presented instead.
- [List of ciphers supported by Fastly](https://developer.fastly.com/learning/concepts/routing-traffic-to-fastly/#use-a-tls-configuration).
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
- `sniHostname` _: string_ _**optional**_
- The SNI hostname to use on connections to this backend.
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
- `clientCertificate` _: object_ _**optional**_
- The client certificate to provide for the TLS handshake
- `certificate` _: string_
- The PEM certificate string.
- `key` _: SecretStoreEntry_
- The `SecretStoreEntry` to use for the key, created via [`SecretStore.prototype.get`](../../fastly:secret-store/SecretStore/prototype/get.mdx) or alteratively via [`SecretStore.fromBytes`](../../fastly:secret-store/SecretStore/fromBytes.mdx).

### Return value

A new `Backend` object.

## Examples

In this example an implicit Dynamic Backend is created when making the fetch request to <https://www.fastly.com/> and the response is then returned to the client.
<Fiddle config={{
"type": "javascript",
"title": "Implicit Dynamic Backend Example",
"origins": [
"https://http-me.glitch.me"
],
"src": {
"deps": "{\n \"@fastly/js-compute\": \"^1.0.1\"\n}",
"main": `
/// <reference types="@fastly/js-compute" />
import { allowDynamicBackends } from "fastly:experimental";
allowDynamicBackends(true);
async function app() {
// For any request, return the fastly homepage -- without defining a backend!
return fetch('https://www.fastly.com/');
}
addEventListener("fetch", event => event.respondWith(app(event)));
`
},
"requests": [
{
"enableCluster": true,
"enableShield": false,
"enableWAF": false,
"method": "GET",
"path": "/status=200",
"useFreshCache": false,
"followRedirects": false,
"tests": "",
"delay": 0
}
],
"srcVersion": 1
}}>

```js
/// <reference types="@fastly/js-compute" />
import { allowDynamicBackends } from "fastly:experimental";
allowDynamicBackends(true);
async function app() {
// For any request, return the fastly homepage -- without defining a backend!
return fetch('https://www.fastly.com/');
}
addEventListener("fetch", event => event.respondWith(app(event)));
```

</Fiddle>

In this example an explicit Dynamic Backend is created and supplied to the fetch request, the response is then returned to the client.


<Fiddle config={{
"type": "javascript",
"title": "Explicit Dynamic Backend Example",
"origins": [
"https://http-me.glitch.me"
],
"src": {
"deps": "{\n \"@fastly/js-compute\": \"^1.0.1\"\n}",
"main": `
/// <reference types="@fastly/js-compute" />
import { allowDynamicBackends } from "fastly:experimental";
import { Backend } from "fastly:backend";
allowDynamicBackends(true);
async function app() {
// For any request, return the fastly homepage -- without defining a backend!
const backend = new Backend({
name: 'fastly',
target: 'fastly.com',
hostOverride: "www.fastly.com",
connectTimeout: 1000,
firstByteTimeout: 15000,
betweenBytesTimeout: 10000,
useSSL: true,
sslMinVersion: 1.3,
sslMaxVersion: 1.3,
});
return fetch('https://www.fastly.com/', {
backend // Here we are configuring this request to use the backend from above.
});
}
addEventListener("fetch", event => event.respondWith(app(event)));
`
},
"requests": [
{
"enableCluster": true,
"enableShield": false,
"enableWAF": false,
"method": "GET",
"path": "/status=200",
"useFreshCache": false,
"followRedirects": false,
"tests": "",
"delay": 0
}
],
"srcVersion": 1
}}>

```js
/// <reference types="@fastly/js-compute" />
import { allowDynamicBackends } from "fastly:experimental";
import { Backend } from "fastly:backend";
allowDynamicBackends(true);
async function app() {
// For any request, return the fastly homepage -- without defining a backend!
const backend = new Backend({
name: 'fastly',
target: 'fastly.com',
hostOverride: "www.fastly.com",
connectTimeout: 1000,
firstByteTimeout: 15000,
betweenBytesTimeout: 10000,
useSSL: true,
sslMinVersion: 1.3,
sslMaxVersion: 1.3,
});
return fetch('https://www.fastly.com/', {
backend // Here we are configuring this request to use the backend from above.
});
}
addEventListener("fetch", event => event.respondWith(app(event)));
```

</Fiddle>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---

# Backend.exists()

The **`Backend.exists()`** method returns a boolean indicating if a Backend with the given name exists or not.

## Syntax

```js
exists(name)
```

### Return value

A boolean indicating if a Backend with the given name exists or not.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---

# Backend.fromName()

Returns the `Backend` instance with the given name, if one exists. If one does not exist, an error is thrown.

## Syntax

```js
fromName(name)
```

### Return value

A `Backend` instance.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---

# Backend.health()

The **`Backend.health()`** method returns a string representing the health of the given Backend instance.

## Syntax

```js
Backend.health(backend)
```

### Return value

A string representing the health of the specified Backend value.

Possible values are:
- `"healthy"` - The backend's health check has succeeded, indicating the backend is working as expected and should receive requests.
- `"unhealthy"` - The backend's health check has failed, indicating the backend is not working as expected and should not receive requests.
- `"unknown"` - The backend does not have a health check configured.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---

# Backend.prototype.toName()

The **`toName()`** method returns the name associated with the `Backend` instance.

## Syntax

```js
toName()
```

### Return value

A string which contains the name of the Backend.
Loading

0 comments on commit 8b4cc26

Please sign in to comment.