Skip to content

Commit 09ab6e8

Browse files
triblondonJakeChampion
authored andcommitted
Revamp overview page of docs
1 parent 0a4cf9b commit 09ab6e8

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

documentation/docs/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/@fastly/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 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)