Skip to main content

aim_deno 0.4.0 copy "aim_deno: ^0.4.0" to clipboard
aim_deno: ^0.4.0 copied to clipboard

Platformweb

Deno adapter for Aim: runs an Aim app on Supabase Edge Functions and other Deno runtimes.

aim_deno #

Run an Aim application on Deno-based runtimes — Supabase Edge Functions, Deno Deploy, Netlify Edge — compiled to WebAssembly with dart compile wasm.

import 'package:aim_deno/aim_deno.dart';

void main() {
  final app = Aim();
  app.get('/', (c) async => c.text('Hello from Dart on Deno'));
  app.serveDeno();
}

serveDeno() registers globalThis.__aimFetch. A small JS entry module instantiates the wasm module on the first request and forwards fetch(request) to it. See example/main.dart in this package for a minimal handler.

This package re-exports aim_edge (which itself re-exports aim_core), so importing package:aim_deno/aim_deno.dart alone is enough to build and run an app.

basePath #

Supabase Edge Functions serve each function under /<function-name> and pass that segment through to the handler: a request for /users/42 arrives with a path of /<function-name>/users/42. An app whose routes are written as / and /users/:id answers 404 on every path unless that segment is stripped first.

app.serveDeno(basePath: 'my_api');

Deno Deploy and Netlify Edge serve at the root and need nothing.

Environment variables #

c.env returns a typed EdgeEnv? (a DenoEnv on this runtime): c.env?.string('GREETING') reads a Deno environment variable, and c.env?.has('GREETING') checks presence. Deno has no resource bindings, so c.env?.get(name) is always null.

Middleware #

The aim_server_* middleware packages (cors, cookie, form, logger, sse, jwt, basic_auth) depend on aim_core and work unchanged on Deno. aim_server_static and aim_server_multipart's saveTo() need the file system and are VM-only.

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.
  • serveDeno() must be called synchronously from main(); the JS entry module expects globalThis.__aimFetch to exist right after invokeMain().
  • Responses with status 101, 204, 205, or 304 are sent without a body regardless of the Dart body.
0
likes
160
points
360
downloads

Documentation

API reference

Publisher

verified publisherdart-forge.dev

Weekly Downloads

Deno adapter for Aim: runs an Aim app on Supabase Edge Functions and other Deno runtimes.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

aim_core, aim_edge, web

More

Packages that depend on aim_deno