SupaBase Dedicated Backend

Hello Everyone, I am new to SupaBase and building a dedicated backend using supabase for my app and I have to make some external api calls from my backend which are not in the db. I was thinking about the folder structure of my supabase app currently I have
./src
├── functions
│ └── get-video-analysis
│ └── index.ts
├── services
│ └── youTube
│ └── video.service.ts
└── types
└── analyzeType.ts

./supabase
├── config.toml
└── functions
└── get-video-analysis
└── index.ts
./src
├── functions
│ └── get-video-analysis
│ └── index.ts
├── services
│ └── youTube
│ └── video.service.ts
└── types
└── analyzeType.ts

./supabase
├── config.toml
└── functions
└── get-video-analysis
└── index.ts
And I am using a script to copy the functions from src to supabase but getting many issues using it . Is there any better way to build a robust backend or should I just directly write into the supabase folder.??
8 Replies
inder
inder3d ago
You can use the folder structure you have now without copying it to supabase directory. I just tested the folder structure you have now and faced no errors. Wherever you keep these functions you also have to update the path in config.toml accordingly. For example, in my screenshot I've set entrypoint and import_map to src directory a level above
No description
No description
inder
inder3d ago
But its generally a good practice to keep all supabase related stuff in supabase dir. Not a rule
Bl@ck@rrow
Bl@ck@rrowOP3d ago
@inder Currently I am trying to call an external api from my backend which require some modification I mean some utility files . So I wanted to know what is the best practice to write this on my way like copying from src or just directly into supabase like
./supabase
├── config.toml
├── functions
│ └── get-video-analysis
│ └── index.ts
├── types
│ └── type.ts
└── utilities
└── util.ts
./supabase
├── config.toml
├── functions
│ └── get-video-analysis
│ └── index.ts
├── types
│ └── type.ts
└── utilities
└── util.ts
The whole thing into supabase??
inder
inder3d ago
If these util files are being imported in functions, then you can move them inside functions dir itself.
Bl@ck@rrow
Bl@ck@rrowOP3d ago
yes they are imported. So it best way is to write all into supabase. Okay, Thank you for help. I was using the normal src and dist structure previously.
inder
inder3d ago
You have the option to do that. I tested with a simple function. Didn't test with import statements. So maybe it breaks there. But generally I've seen people keep supabase related stuff inside supabase dir.
Bl@ck@rrow
Bl@ck@rrowOP3d ago
Initially I was getting error about import issues like @ and ./ ../
inder
inder3d ago
yeah imports must be breaking for files outside.

Did you find this page helpful?