Default starter for AssemblyScript
Get to know the Fastly Compute@Edge environment with a basic starter that demonstrates routing, simple synthetic responses and overriding caching rules.
Using the Fastly CLI, create a new project using this starter somewhere on your computer:
$ fastly compute init --from=https://github.com/fastly/compute-starter-kit-assemblyscript-default
- Add headers to an inbound request
- Allow only requests with particular HTTP methods
- Match request URL path and methods for routing
- Build synthetic responses at the edge
- Send requests to a backend
- Override caching policy response headers
This starter is intentionally lightweight, and requires no dependencies aside from the
@fastly/as-compute package. It will help you understand the basics of processing requests at the edge using Fastly. This starter includes implementations of common patterns explained in our using Compute@Edge and VCL migration guides.
/backend will attempt to send a request to a backend called "backend_name". If the service you have installed this starter on doesn't have a backend defined, use the
fastly backend create command to create one. Modify the following lines of the starter to use the name of the backend you created:
// The name of a backend server associated with this service.//// This should be changed to match the name of your own backend. See the the// `Hosts` section of the Fastly Wasm service UI for more information.const BACKEND_NAME = "backend_name";/// The name of a second backend associated with this service.const OTHER_BACKEND_NAME = "other_backend_name";
The starter uses two backends, so if you want to, go ahead and create two backends using the CLI and then modify both names here. You should now have a Fastly service running on Compute@Edge that can talk to your backends, and generate synthetic responses at the edge.
Starters are a good way to bootstrap a project. For more specific use cases, and answers to common problems, try our library of code examples.