-
Notifications
You must be signed in to change notification settings - Fork 452
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
Merged
kallebysantos
merged 15 commits into
supabase:develop
from
kallebysantos:feat-update-functions-template-server-sdk
May 6, 2026
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2bc9fc5
feat: creating auth access templates
kallebysantos 7a81831
test: fix tests
kallebysantos 8622712
fix: wrong format type
kallebysantos 1294464
test: adding tests for auth templates
kallebysantos 0008c37
fix: improving 'always' template description
kallebysantos 5d85cff
stamp: changing default function template to 'apikey'
kallebysantos aca125d
fix: using default value from 'EnumFlag' util
kallebysantos 170e362
stamp: format
kallebysantos 65e10ed
fix: adding missing backslash on invoke command
kallebysantos 9d8c4fd
fix: use new server sdk API syntax
kallebysantos 733155b
stamp: pin '@supabase/server' to v1
kallebysantos 32f9b4c
stamp: codegen
kallebysantos 59f0197
stamp: renaming 'AuthAccessMode*' to 'AuthMode' terminology
kallebysantos 6941356
stamp: renaming template files to match 'AuthMode' terminology
kallebysantos 382befc
fix: template comment
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@^1" | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
internal/functions/new/templates/index_auth_mode_apikey.ts
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 'publishable' | 'secret' access, apiKey is required. | ||
| // Use publishable for Client-facing, key-validated endpoints | ||
| // Use secret for Server-to-server, internal calls | ||
| export default { | ||
| fetch: withSupabase({ auth: ["publishable", "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
| 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 auth 'none', 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({ auth: "none" }, 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
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.