invertase / dart_edge

Run Dart on the Edge - supporting Vercel & Cloudflare Workers (more coming soon).

Home Page:https://docs.dartedge.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple functions support ?

gaetschwartz opened this issue · comments

I've browsed around but I'm not sure to understand how it is intended to be used to use multiple functions. Do we need one dart project for each function ?

You could use a monorepo with a tool like https://github.com/invertase/melos; each function could be a private package in ./packages for example. You can easily share local dependencies and build/deploy scripts with Melos too.

But AFAIK when using edge build supabase_functions --dev it always builds it as supabase/functions/dart-edge ? For now I build and rename the folder automatically. Also, edge build supabase_functions does not seem to work on my end. It just completes without doing anything (#24)

Yeah thus was part of my thinking for #12

You can define entrypoints -> name. I'll have a think.

DM'd you on Twitter about that :) @Ehesp

My workflow looks like --

  1. Create new function with edge new supabase_functions example_dart
  2. cd example_dart && build supabase_functions --dev
  3. rename example_dart/supabase/functions/dart_edge to example_dartgen
  4. move example_dartgen to parent supabase/functions, next to original example_dart

So my folder looks like:

-supabase
 -functions
  -example_dart
  -example_dartgen
  -packages

Seems to be working well for organizes so far, maybe it will help others manage multiple functions.

I also am having issues using this with multiple functions. Ideally, I think I'd like to have a mirrored folder structure. Basically /edge/functions/[my_function_name] of which there can be N functions and then once edge build supabase_functions is called, it builds each function in /edge/functions/ and outputs to /supabase/functions/*.

Alternatively, if the edge build supabase_functions accepted input/output args, I could make this behavior myself.

Currently, this tool seems to assume it will manage the entire dart package and be the only function in supabase. This is not necessarily the case since sometimes your package includes multiple aspect of your backend and sometimes even your frontend (as is often the case with supabase + frontend in one repo)