Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fastly/as-compute

Package Overview
Dependencies
Maintainers
47
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastly/as-compute

![npm version](https://img.shields.io/npm/v/@fastly/as-compute) ![npm downloads per month](https://img.shields.io/npm/dm/@fastly/as-compute)

  • 0.1.2
  • npm
  • Socket score

Version published
Weekly downloads
53
increased by82.76%
Maintainers
47
Weekly downloads
 
Created
Source

as-compute

npm version npm downloads per month

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 the exposed `@fastly/as-fetch`'s Fetch API classes,
// and `Fastly` to interact with Fastly's Compute@Edge.
import { Request, Response, Headers, Fastly } from "@fastly/as-compute";

// Create some headers for our upstream request to our origin.
let upstreamHeaders = new Headers();
upstreamHeaders.set("UpstreamHeader", "UpstreamValue");

// Create our upstream request to our origin using our upstream headers.
let upstreamRequest = new Request("http://provider.org/TheURL", {
  method: "GET",
  headers: upstreamHeaders,
});

// Send the upstream request with `Fastly.fetch` and wait to get our response.
let upstreamResponse = Fastly.fetch(upstreamRequest, {
  backend: "TheOrigin",
}).wait();

// Create some headers for the downstream response that we will be sending back to our client.
let downstreamHeaders = new Headers();
downstreamHeaders.set("DownstreamHeader", "DownstreamValue");

// Create the downstream response with our new headers, but pass along the upstream response body.
let downstreamResponse = new Response(upstreamRequest.arrayBuffer(), {
  headers: downstreamHeaders,
});

// Send the downstream response back down to the client! :)
Fastly.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

FAQs

Package last updated on 10 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc