aim_edge 0.4.0
aim_edge: ^0.4.0 copied to clipboard
Shared plumbing for running Aim applications on edge runtimes. Adapter authors build on this; application authors use aim_workers or aim_deno instead.
aim_edge #
Shared plumbing for running an Aim application on an edge runtime: the translation between the platform's Request/Response and Aim's Request/Response, the EdgeEnv interface for runtime bindings, and the c.env context getter.
This package is not an adapter by itself and has no serve*() method. Application authors depend on one of the runtime adapters built on it instead:
aim_workersfor Cloudflare workerd (Cloudflare Workers)aim_denofor Deno-based runtimes (Supabase Edge Functions, Deno Deploy, Netlify Edge)
Both re-export aim_edge, so an application only needs to depend on the adapter it targets.
Two entry points #
package:aim_edge/aim_edge.dart— for application code. Re-exportsaim_coreplusEdgeEnvand thec.envgetter.package:aim_edge/adapter.dart— for adapter authors. ExposesEdgeEnv,EdgeRaw,handleEdgeFetch,toAimRequest, andtoWebResponse, the pieces a new adapter needs to translate its runtime'sfetchhandler into anAimrequest.
Writing a new adapter #
An adapter package implements EdgeRaw for its runtime (wrapping the platform's Request and exposing an EdgeEnv), then registers globalThis.__aimFetch by calling handleEdgeFetch(app, EdgeRawImpl(request)) from a serve*() extension on Aim. See aim_workers' and aim_deno's lib/src/ for worked examples.
Limitations (v1) #
- Request bodies are read fully into memory before the handler runs.
- Response bodies are streamed without backpressure; fast producers buffer in the JS queue.
- Responses with status 101, 204, 205, or 304 are sent without a body regardless of the Dart body.