An Edge Function in Dart

An Edge Function does not have to be TypeScript. spring_boot_starter_edge compiles a Spring for Dart application to JavaScript and writes the index.ts Supabase's Edge Runtime needs; with this starter in the application, the function reaches the project as the caller. See Supabase Edge Functions for the settings.

example/supabase/function is such a function, named api. Its main is:

@SpringBootApplication()
void main() => runFetchApplication(() => springApplication);
dart run build_runner build
dart run spring_boot_starter_edge:build \
  --platform supabase --name api \
  --output ../supabase/functions/api

What it shows

@PostMapping()
@ResponseStatus(HttpStatus.created)
@RateLimiter('10/1m', key: '#{authentication.name}', name: 'add-todo')
Future<Todo> add(@RequestBody() @Valid() NewTodo todo) => todos.save(
  Todo(
    title: todo.title,
    listId: todo.listId,
    createdAt: DateTime.now().toUtc(),
  ),
);

The example project has no function written in TypeScript: these two are endpoints of this one.

The function is [functions.api] with verify_jwt = false in the example's config.toml, and SPRING_SUPABASE_AUTH_ISSUER under [edge_runtime.secrets] for the local stack.

See also