invertase / dart_edge

Run Dart on the Edge - supporting Vercel & Cloudflare Workers (more coming soon).
https://docs.dartedge.dev
Apache License 2.0
322 stars 23 forks source link

Multiple functions support ? #23

Closed gaetschwartz closed 1 year ago

gaetschwartz commented 1 year ago

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 ?

Salakar commented 1 year ago

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.

gaetschwartz commented 1 year ago

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)

Ehesp commented 1 year ago

Yeah thus was part of my thinking for https://github.com/invertase/dart_edge/issues/12

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

gaetschwartz commented 1 year ago

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

MichealReed commented 1 year ago

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.

point-source commented 1 year ago

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)