Skip to content

Commit 671bcea

Browse files
author
Jake Champion
committed
chore: correct documentation
1 parent 913eb40 commit 671bcea

File tree

54 files changed

+198490
-663
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+198490
-663
lines changed

documentation/app/fastly.toml

Lines changed: 197992 additions & 0 deletions
Large diffs are not rendered by default.

documentation/docs/fastly:cache/SimpleCache/get.mdx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ If the key does exist in the cache, this returns a `SimpleCacheEntry`.
3737

3838
## Examples
3939

40-
In this example we attempt to retrieve an entry from the Fastly Cache, if the entry does not exist, we create the content and insert it into the Fastly Cache before finally returning.
40+
In this example we attempt to retrieve an entry from the Fastly Cache, and return a message stating whether the entry was in the Fastly Cache or not.
4141

4242
```js
4343
/// <reference types="@fastly/js-compute" />
@@ -47,14 +47,9 @@ import { SimpleCache } from 'fastly:cache';
4747
addEventListener('fetch', event => event.respondWith(app(event)));
4848

4949
async function app(event) {
50-
const path = new URL(event.request).pathname;
50+
const path = new URL(event.request.url).pathname;
5151
let page = SimpleCache.get(path);
52-
if (!page) {
53-
page = await render(path);
54-
// Store the page in the cache for 1 minute.
55-
SimpleCache.set(path, page, 60);
56-
}
57-
return new Response(page, {
52+
return new Response(page ? `${path} is in the cache` : `${path} is not in the cache`, {
5853
headers: {
5954
'content-type': 'text/plain;charset=UTF-8'
6055
}

documentation/docs/fastly:cache/SimpleCache/set.mdx

Lines changed: 0 additions & 77 deletions
This file was deleted.

documentation/docs/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {Fiddle} from '@site/src/components/fiddle';
1010

1111
# JavaScript for Compute@Edge
1212

13-
This site is the full SDK reference for [@fastly/js-compute](https://www.npmjs.com/package/@fastly/js-compute), the module that provides the interface between your JavaScript code and the [Fastly](https://www.fastly.com) Compute@Edge platform.
13+
This site is the full SDK reference for [`@fastly/js-compute`](https://www.npmjs.com/package/%40fastly/js-compute), the module that provides the interface between your JavaScript code and the [Fastly](https://www.fastly.com) Compute@Edge platform.
1414

1515
If you haven't used Compute@Edge before, start by [setting up your first Compute@Edge program](https://developer.fastly.com/learning/compute/) over on **developer.fastly.com** so that you have a working development environment.
1616

@@ -95,4 +95,4 @@ addEventListener("fetch", event => {
9595

9696
</Fiddle>
9797

98-
Check out [`fiddle.fastly.dev`](https://fiddle.fastly.dev] to create your own.
98+
Check out [`fiddle.fastly.dev`](https://fiddle.fastly.dev) to create your own.

documentation/versioned_docs/version-1.0.0/index.mdx

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,41 @@ pagination_prev: null
88

99
import {Fiddle} from '@site/src/components/fiddle';
1010

11-
# Getting started
11+
# JavaScript for Compute@Edge
1212

13-
First, make sure to have [Fastly's CLI](https://developer.fastly.com/learning/tools/cli/) installed:
13+
This site is the full SDK reference for [`@fastly/js-compute`](https://www.npmjs.com/package/%40fastly/js-compute), the module that provides the interface between your JavaScript code and the [Fastly](https://www.fastly.com) Compute@Edge platform.
1414

15-
The Fastly CLI is available for multiple operating systems.
15+
If you haven't used Compute@Edge before, start by [setting up your first Compute@Edge program](https://developer.fastly.com/learning/compute/) over on **developer.fastly.com** so that you have a working development environment.
1616

17-
- **MacOS**: Install from Homebrew:
17+
To learn more about the fundamentals of using JavaScript with Compute@Edge, see our [using JavaScript](https://developer.fastly.com/learning/compute/javascript/) guide.
1818

19-
```
20-
brew install fastly/tap/fastly
21-
```
19+
## Understanding the JavaScript SDK
2220

23-
- **Windows**: [Visit the GitHub repository](https://github.com/fastly/cli/releases/latest) to download the prebuilt binary for your architecture.
24-
- **Linux**: Packages are available for many distributions, along with prebuilt binaries. [Visit the GitHub repository](https://github.com/fastly/cli/releases/latest) to download the package for your distribution.
21+
Incoming HTTP requests to [domains that are attached to your Fastly service](https://developer.fastly.com/learning/concepts/) will start an instance of your application and invoke a `fetch` event, which can be bound using the `addEventListener` function:
2522

26-
## Initialise a new project
23+
```js
24+
addEventListener("fetch", event => event.respondWith(handleRequest(event)) );
2725

28-
Create a new Fastly Compute@Edge JavaScript project:
26+
async function handleRequest(event) {
27+
const req = event.request;
2928

30-
```shell
31-
fastly compute init --language javascript --from https://github.com/fastly/compute-starter-kit-javascript-empty
29+
return fetch(req, {
30+
backend: "example_backend"
31+
});
32+
}
3233
```
3334

34-
Install the dependencies:
35+
Fastly specific features are available as named imports from `fastly:` prefixed modules, all of which are documented in this site. For example, the [env](https://js-compute-reference-docs.edgecompute.app/docs/fastly:env/env) function provides access to [environment variables](https://developer.fastly.com/reference/compute/ecp-env/) and can be imported into your application like this:
3536

36-
```
37-
npm install
37+
```js
38+
import { env } from "fastly:env"
3839
```
3940

40-
## Try it out locally
41+
JavaScript code compiled for Compute@Edge has access to a global environment with most of the globals you would expect in an ECMAScript runtime, like [`Date`](https://js-compute-reference-docs.edgecompute.app/docs/globals/Date/) and [`console`](https://js-compute-reference-docs.edgecompute.app/docs/globals/console/log).
4142

43+
## Trying things out
4244

43-
```shell
44-
fastly compute serve --watch
45-
```
46-
47-
Your application should now be running on [http://localhost:7676](http://localhost:7676)
48-
45+
[Fastly fiddle](https://fiddle.fastly.dev) is an online web-based playground where you can run Fastly code. You'll see fiddles included in many pages of our [developer hub](https://developer.fastly.com) and this SDK reference. These interactive examples can be executed right on the page by clicking the **RUN** tab:
4946

5047
<Fiddle config={{
5148
"type": "javascript",
@@ -54,7 +51,7 @@ Your application should now be running on [http://localhost:7676](http://localho
5451
"https://http-me.glitch.me"
5552
],
5653
"src": {
57-
"deps": "{\n \"@fastly/js-compute\": \"^1.0.0\"\n}",
54+
"deps": "{\n \"@fastly/js-compute\": \"^1.0.1\"\n}",
5855
"main": `
5956
/// <reference types="@fastly/js-compute" />
6057
async function app(event) {
@@ -97,3 +94,5 @@ addEventListener("fetch", event => {
9794
```
9895

9996
</Fiddle>
97+
98+
Check out [`fiddle.fastly.dev`](https://fiddle.fastly.dev) to create your own.

documentation/versioned_docs/version-1.1.0/index.mdx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,41 @@ pagination_prev: null
88

99
import {Fiddle} from '@site/src/components/fiddle';
1010

11-
# Getting started
11+
# JavaScript for Compute@Edge
1212

13-
First, make sure to have [Fastly's CLI](https://developer.fastly.com/learning/tools/cli/) installed:
13+
This site is the full SDK reference for [`@fastly/js-compute`](https://www.npmjs.com/package/%40fastly/js-compute), the module that provides the interface between your JavaScript code and the [Fastly](https://www.fastly.com) Compute@Edge platform.
1414

15-
The Fastly CLI is available for multiple operating systems.
15+
If you haven't used Compute@Edge before, start by [setting up your first Compute@Edge program](https://developer.fastly.com/learning/compute/) over on **developer.fastly.com** so that you have a working development environment.
1616

17-
- **MacOS**: Install from Homebrew:
17+
To learn more about the fundamentals of using JavaScript with Compute@Edge, see our [using JavaScript](https://developer.fastly.com/learning/compute/javascript/) guide.
1818

19-
```
20-
brew install fastly/tap/fastly
21-
```
19+
## Understanding the JavaScript SDK
2220

23-
- **Windows**: [Visit the GitHub repository](https://github.com/fastly/cli/releases/latest) to download the prebuilt binary for your architecture.
24-
- **Linux**: Packages are available for many distributions, along with prebuilt binaries. [Visit the GitHub repository](https://github.com/fastly/cli/releases/latest) to download the package for your distribution.
21+
Incoming HTTP requests to [domains that are attached to your Fastly service](https://developer.fastly.com/learning/concepts/) will start an instance of your application and invoke a `fetch` event, which can be bound using the `addEventListener` function:
2522

26-
## Initialise a new project
23+
```js
24+
addEventListener("fetch", event => event.respondWith(handleRequest(event)) );
2725

28-
Create a new Fastly Compute@Edge JavaScript project:
26+
async function handleRequest(event) {
27+
const req = event.request;
2928

30-
```shell
31-
fastly compute init --language javascript --from https://github.com/fastly/compute-starter-kit-javascript-empty
29+
return fetch(req, {
30+
backend: "example_backend"
31+
});
32+
}
3233
```
3334

34-
Install the dependencies:
35+
Fastly specific features are available as named imports from `fastly:` prefixed modules, all of which are documented in this site. For example, the [env](https://js-compute-reference-docs.edgecompute.app/docs/fastly:env/env) function provides access to [environment variables](https://developer.fastly.com/reference/compute/ecp-env/) and can be imported into your application like this:
3536

36-
```
37-
npm install
37+
```js
38+
import { env } from "fastly:env"
3839
```
3940

40-
## Try it out locally
41+
JavaScript code compiled for Compute@Edge has access to a global environment with most of the globals you would expect in an ECMAScript runtime, like [`Date`](https://js-compute-reference-docs.edgecompute.app/docs/globals/Date/) and [`console`](https://js-compute-reference-docs.edgecompute.app/docs/globals/console/log).
4142

43+
## Trying things out
4244

43-
```shell
44-
fastly compute serve --watch
45-
```
46-
47-
Your application should now be running on [http://localhost:7676](http://localhost:7676)
45+
[Fastly fiddle](https://fiddle.fastly.dev) is an online web-based playground where you can run Fastly code. You'll see fiddles included in many pages of our [developer hub](https://developer.fastly.com) and this SDK reference. These interactive examples can be executed right on the page by clicking the **RUN** tab:
4846

4947
<Fiddle config={{
5048
"type": "javascript",
@@ -96,3 +94,5 @@ addEventListener("fetch", event => {
9694
```
9795

9896
</Fiddle>
97+
98+
Check out [`fiddle.fastly.dev`](https://fiddle.fastly.dev) to create your own.

documentation/versioned_docs/version-1.10.0/index.mdx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,41 @@ pagination_prev: null
88

99
import {Fiddle} from '@site/src/components/fiddle';
1010

11-
# Getting started
11+
# JavaScript for Compute@Edge
1212

13-
First, make sure to have [Fastly's CLI](https://developer.fastly.com/learning/tools/cli/) installed:
13+
This site is the full SDK reference for [`@fastly/js-compute`](https://www.npmjs.com/package/%40fastly/js-compute), the module that provides the interface between your JavaScript code and the [Fastly](https://www.fastly.com) Compute@Edge platform.
1414

15-
The Fastly CLI is available for multiple operating systems.
15+
If you haven't used Compute@Edge before, start by [setting up your first Compute@Edge program](https://developer.fastly.com/learning/compute/) over on **developer.fastly.com** so that you have a working development environment.
1616

17-
- **MacOS**: Install from Homebrew:
17+
To learn more about the fundamentals of using JavaScript with Compute@Edge, see our [using JavaScript](https://developer.fastly.com/learning/compute/javascript/) guide.
1818

19-
```
20-
brew install fastly/tap/fastly
21-
```
19+
## Understanding the JavaScript SDK
2220

23-
- **Windows**: [Visit the GitHub repository](https://github.com/fastly/cli/releases/latest) to download the prebuilt binary for your architecture.
24-
- **Linux**: Packages are available for many distributions, along with prebuilt binaries. [Visit the GitHub repository](https://github.com/fastly/cli/releases/latest) to download the package for your distribution.
21+
Incoming HTTP requests to [domains that are attached to your Fastly service](https://developer.fastly.com/learning/concepts/) will start an instance of your application and invoke a `fetch` event, which can be bound using the `addEventListener` function:
2522

26-
## Initialise a new project
23+
```js
24+
addEventListener("fetch", event => event.respondWith(handleRequest(event)) );
2725

28-
Create a new Fastly Compute@Edge JavaScript project:
26+
async function handleRequest(event) {
27+
const req = event.request;
2928

30-
```shell
31-
fastly compute init --language javascript --from https://github.com/fastly/compute-starter-kit-javascript-empty
29+
return fetch(req, {
30+
backend: "example_backend"
31+
});
32+
}
3233
```
3334

34-
Install the dependencies:
35+
Fastly specific features are available as named imports from `fastly:` prefixed modules, all of which are documented in this site. For example, the [env](https://js-compute-reference-docs.edgecompute.app/docs/fastly:env/env) function provides access to [environment variables](https://developer.fastly.com/reference/compute/ecp-env/) and can be imported into your application like this:
3536

36-
```
37-
npm install
37+
```js
38+
import { env } from "fastly:env"
3839
```
3940

40-
## Try it out locally
41+
JavaScript code compiled for Compute@Edge has access to a global environment with most of the globals you would expect in an ECMAScript runtime, like [`Date`](https://js-compute-reference-docs.edgecompute.app/docs/globals/Date/) and [`console`](https://js-compute-reference-docs.edgecompute.app/docs/globals/console/log).
4142

43+
## Trying things out
4244

43-
```shell
44-
fastly compute serve --watch
45-
```
46-
47-
Your application should now be running on [http://localhost:7676](http://localhost:7676)
45+
[Fastly fiddle](https://fiddle.fastly.dev) is an online web-based playground where you can run Fastly code. You'll see fiddles included in many pages of our [developer hub](https://developer.fastly.com) and this SDK reference. These interactive examples can be executed right on the page by clicking the **RUN** tab:
4846

4947
<Fiddle config={{
5048
"type": "javascript",
@@ -96,3 +94,5 @@ addEventListener("fetch", event => {
9694
```
9795

9896
</Fiddle>
97+
98+
Check out [`fiddle.fastly.dev`](https://fiddle.fastly.dev) to create your own.

0 commit comments

Comments
 (0)