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

compute-starter-kit-javascript-default

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compute-starter-kit-javascript-default

Experiment with running JavaScript in the Fastly Compute@Edge environment with a basic starter that demonstrates rudimentary request handling.

  • 0.2.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Compute@Edge starter kit for JavaScript

Experiment with running JavaScript in the Fastly Compute@Edge environment with a basic starter that demonstrates rudimentary request handling.

For more details about other starter kits for Compute@Edge, see the Fastly developer hub

Features

  • Handling incoming requests via a handler for the fetch event
  • Getting the incoming request via event.request
  • Basic handling of requests, including
    • reading headers and request bodies using request.text(), request.arrayBuffer(), request.json()
    • reading request headers using request.headers
  • Setting response bodies via the Response constructor (but not the body setter)
  • Setting response headers via the Response#headers getter
  • Sending async upstream requests using fetch(request, { backend: "backend_name" })
  • Reading values from Edge Dictionaries using the Dictionary builtin
  • Getting the client's IP address via event.client.address
  • Getting the client's geolocation data via event.client.geo
  • Getting geolocation data for any IP address via getGeolocationForIpAddress

Understanding the code

The code in src/index.js registers a handler for the fetch event that takes an event object with the downstream request as a request property, and shows how to read the URL, request body and headers, and send a response.

The template uses webpack to bundle index.js and its imports into a single JS file, bin/index.js, which is then wrapped into a .wasm file, bin/index.wasm using the js-compute-runtime CLI tool bundled with the @fastly/js-compute npm package, and bundled into a .tar.gz file ready for deployment to Compute@Edge.

After deployment, your Compute@Edge service will simply return an iframe with instructions on how to get started with C@E. For more complex examples of what can be done within a Compute@Edge program, see the usage guide for JavaScript or our library of code examples.

Security issues

Please see our SECURITY.md for guidance on reporting security-related issues.

FAQs

Package last updated on 01 Nov 2021

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