-
Notifications
You must be signed in to change notification settings - Fork 432
feat(functions) update functions template to match new 'server' style #5063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kallebysantos
wants to merge
6
commits into
supabase:develop
Choose a base branch
from
kallebysantos:feat-update-functions-template-server-sdk
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8f67753
feat: creating auth access templates
kallebysantos a459d7a
test: fix tests
kallebysantos 7c67467
fix: wrong format type
kallebysantos e5e44e9
test: adding tests for auth templates
kallebysantos d6fa851
fix: improving 'always' template description
kallebysantos 6b96df4
stamp: changing default function template to 'apikey'
kallebysantos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
|
|
||
| [functions.{{ . }}] | ||
| [functions.{{ .Slug }}] | ||
| enabled = true | ||
| verify_jwt = true | ||
| import_map = "./functions/{{ . }}/deno.json" | ||
| verify_jwt = {{ .VerifyJWT }} | ||
| import_map = "./functions/{{ .Slug }}/deno.json" | ||
| # Uncomment to specify a custom file path to the entrypoint. | ||
| # Supported file extensions are: .ts, .js, .mjs, .jsx, .tsx | ||
| entrypoint = "./functions/{{ . }}/index.ts" | ||
| entrypoint = "./functions/{{ .Slug }}/index.ts" | ||
| # Specifies static files to be bundled with the function. Supports glob patterns. | ||
| # For example, if you want to serve static HTML pages in your function: | ||
| # static_files = [ "./functions/{{ . }}/*.html" ] | ||
| # static_files = [ "./functions/{{ .Slug }}/*.html" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "imports": { | ||
| "@supabase/functions-js": "jsr:@supabase/functions-js@^2" | ||
| "@supabase/functions-js": "jsr:@supabase/functions-js@^2", | ||
| "@supabase/server": "npm:@supabase/server" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Follow this setup guide to integrate the Deno language server with your editor: | ||
| // https://deno.land/manual/getting_started/setup_your_environment | ||
| // This enables autocomplete, go to definition, etc. | ||
|
|
||
| // Setup type definitions for built-in Supabase Runtime APIs | ||
| import "@supabase/functions-js/edge-runtime.d.ts"; | ||
| import { withSupabase } from "@supabase/server"; | ||
|
|
||
| console.log("Hello from Functions!"); | ||
|
|
||
| // This endpoint uses 'always' access, no credentials required, every request is accepted. | ||
| // Use it for health checks, public APIs, or when you need to implement your own auth logic. | ||
| export default { | ||
| fetch: withSupabase({ allow: "always" }, async (req, ctx) => { | ||
| const { name } = await req.json(); | ||
|
|
||
| return Response.json({ | ||
| message: `Hello ${name}!`, | ||
| }); | ||
| }), | ||
| }; | ||
|
|
||
| /* To invoke locally: | ||
|
|
||
| 1. Run `supabase start` (see: https://supabase.com/docs/reference/cli/supabase-start) | ||
| 2. Make an HTTP request: | ||
|
|
||
| curl -i --location --request POST '{{ .URL }}' \ | ||
| --header 'Content-Type: application/json' \ | ||
| --data '{"name":"Functions"}' | ||
|
|
||
| */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Follow this setup guide to integrate the Deno language server with your editor: | ||
| // https://deno.land/manual/getting_started/setup_your_environment | ||
| // This enables autocomplete, go to definition, etc. | ||
|
|
||
| // Setup type definitions for built-in Supabase Runtime APIs | ||
| import "@supabase/functions-js/edge-runtime.d.ts"; | ||
| import { withSupabase } from "@supabase/server"; | ||
|
|
||
| console.log("Hello from Functions!"); | ||
|
|
||
| // This endpoint uses 'public' | 'secret' access, apiKey is required. | ||
| // Use public for Client-facing, key-validated endpoints | ||
| // Use secret for Server-to-server, internal calls | ||
| export default { | ||
| fetch: withSupabase({ allow: ["public", "secret"] }, async (req, ctx) => { | ||
| // Called by another service with a secret key | ||
| // ctx.supabaseAdmin bypasses RLS — use for privileged operations | ||
| /* | ||
| if (ctx.authType === "secret") { | ||
| const { user_id } = await req.json(); | ||
| const { data } = await ctx.supabaseAdmin.auth.admin.getUserById(user_id); | ||
|
|
||
| return Response.json({ | ||
| email: data?.user?.email, | ||
| }); | ||
| } | ||
| */ | ||
|
|
||
| const { name } = await req.json(); | ||
|
|
||
| return Response.json({ | ||
| message: `Hello ${name}!`, | ||
| }); | ||
| }), | ||
| }; | ||
|
|
||
| /* To invoke locally: | ||
|
|
||
| 1. Run `supabase start` (see: https://supabase.com/docs/reference/cli/supabase-start) | ||
| 2. Make an HTTP request: | ||
|
|
||
| curl -i --location --request POST '{{ .URL }}' \ | ||
| --header 'apiKey: {{ .PublishableKey }}' \ | ||
| --data '{"name":"Functions"}' | ||
|
|
||
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.