Dart で書く Edge Function

Edge Function は TypeScript でなくてもかまいません。spring_boot_starter_edge は、Spring for Dart のアプリケーションを JavaScript にコンパイルし、Supabase の Edge Runtime が必要とする index.ts を書きます。アプリケーションにこのスターターがあれば、関数は呼び出し元としてプロジェクトに届きます。設定は Supabase Edge Functions を参照してください。

example/supabase/function がそのような関数で、名前は api です。その main は次のとおりです。

@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

示しているもの

@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(),
  ),
);

サンプルのプロジェクトには、TypeScript で書かれた関数はありません。この二つは、この関数のエンドポイントです。

関数は、サンプルの config.toml で verify_jwt = false の [functions.api] となり、ローカルスタックのために [edge_runtime.secrets] に SPRING_SUPABASE_AUTH_ISSUER があります。

関連項目