Skip to content

Commit 53a8d35

Browse files
committed
edge function doc
1 parent f24ad13 commit 53a8d35

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

.docs/_cron.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ See [Supabase Documentation](https://supabase.com/docs/guides/cron).
66

77
You have to run the following commands in SQL Editor of your Supabase project.
88

9+
## Generate cron tab
10+
11+
1. Fill out root `.env` file with variables
12+
2. run tests: `deno run tests`
13+
3. cron install queries will be generated into the file `cron_jobs.sql` in the root
14+
4. visit supabase dashboard and run these queries in SQL editor
15+
916
## GUI
1017

1118
There is actually a UI where you can manage your jobs very easily.
@@ -16,18 +23,12 @@ https://supabase.com/dashboard/project/***/integrations/cron/jobs
1623

1724
*Replace your project ID in the URL*.
1825

19-
## Create a new job
20-
21-
Fill out .env file with variables and run tests. Cron will be generated to the file.
22-
23-
```bash
24-
deno run tests
25-
```
26-
2726
## Remove existing job
2827

2928
Replace ID by number from your database of already existing cron.
3029

3130
```bash
3231
select cron.unschedule(3);
3332
```
33+
34+
Or you can do this via GUI as well.

.docs/_edge_functions.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Edge Functions
2+
3+
Basically the same as AWS Lambda, but much better integrated in the whole system. Check [Supabase Documentation](https://supabase.com/docs/guides/functions).
4+
5+
Code is located in: `./supabase/functions/*`.
6+
7+
Each function can run a very short time (up to 2s) then it's terminated. So it's good to write small scripts with pagination. Database can give you great tooling for that.
8+
9+
Unexpected errors are handled by Sentry. That works good. What should be tweaked is notification about terminated function. It can be done probably by event pushing to Sentry as well.
10+
11+
12+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The purpose of this project is to store data about the music I listen to in my o
66
I also want to have fun while learning more about [Supabase](https://supabase.com) native features.
77

88
Currently, I am downloading all historical data from my Last.fm profile
9-
using its API to PostgresSQL via [Edge Functions](https://supabase.com/docs/guides/functions) and the [built-in cron extension](https://supabase.com/docs/guides/cron),
9+
using its API to PostgresSQL via [Edge Functions](.docs/_edge_functions.md) and the [built-in cron extension](.docs/_cron.md),
1010
which run every 5 minutes and download 500 items.
1111

1212
## Roadmap

0 commit comments

Comments
 (0)