as-compute
Experimental AssemblyScript SDK for building Compute@Edge applications with AssemblyScript.
Installation
@fastly/as-compute
is available as a npm package. You can install @fastly/as-compute
in your AssemblyScript project by running:
npm install --save @fastly/as-compute
Quick Start
NOTE: Usage with the Fastly CLI will be coming soon!
Let's take a quick look at an example that:
- makes a request to the origin server
- creates a new response that modifies the origin response
import { Request, Response, Headers, Fetchly } from "@fastly/as-compute";
let upstreamHeaders = new Headers();
upstreamHeaders.set("UpstreamHeader", "UpstreamValue");
let upstreamRequest = new Request("http://provider.org/TheURL", {
method: "GET",
headers: upstreamHeaders,
});
let upstreamResponse = Fetchly.fetch(upstreamRequest, {
backend: "TheOrigin",
}).wait();
let downstreamHeaders = new Headers();
downstreamHeaders.set("DownstreamHeader", "DownstreamValue");
let downstreamResponse = new Response(upstreamRequest.arrayBuffer(), {
headers: downstreamHeaders,
});
Fetchly.respondWith(downstreamResponse);
Examples
NOTE: Coming soon to the Fastly Developer Hub!
API Reference
The API reference documentation can be found in the docs/
directory.
Security
If you find any security issues, see the Fastly Security Reporting Page or send an email to: security@fastly.com
We plan to disclose any found security vulnerabilities per the npm vulnerability reporting guidelines. Note that communications related to security issues in Fastly-maintained OSS as described here are distinct from Fastly security advisories.
License
Apache-2.0 WITH LLVM-exception