Skip to content

feat(functions) update functions template to match new 'server' style#5063

Open
kallebysantos wants to merge 9 commits intosupabase:developfrom
kallebysantos:feat-update-functions-template-server-sdk
Open

feat(functions) update functions template to match new 'server' style#5063
kallebysantos wants to merge 9 commits intosupabase:developfrom
kallebysantos:feat-update-functions-template-server-sdk

Conversation

@kallebysantos
Copy link
Copy Markdown
Member

@kallebysantos kallebysantos commented Apr 10, 2026

What kind of change does this PR introduce?

Feature

What is the new behavior?

Apply withSupabase helper from @supabase/server

Additional context

A new optional flag --auth was introduced for the functions new command, chose between the auth access template:

  • always No credentials required - Open endpoints, wrappers that handle their own auth
  • apikey Valid publishable key or secret key - Use respectively for Client-facing, key-validated endpoints or Server-to-server, internal calls
  • user User JWT required - Authenticated user endpoints

Current default --auth apikey

--
Towards FUNC-563

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 10, 2026

Coverage Report for CI Build 25128379328

Coverage decreased (-0.04%) to 63.715%

Details

  • Coverage decreased (-0.04%) from the base build.
  • Patch coverage: 5 uncovered changes across 2 files (19 of 24 lines covered, 79.17%).
  • 11 coverage regressions across 4 files.

Uncovered Changes

File Changed Covered %
cmd/functions.go 4 1 25.0%
internal/functions/new/new.go 20 18 90.0%

Coverage Regressions

11 previously-covered lines in 4 files lost coverage.

File Lines Losing Coverage Coverage
internal/utils/git.go 5 57.14%
internal/debug/postgres.go 3 66.09%
internal/storage/rm/rm.go 2 80.61%
cmd/functions.go 1 45.92%

Coverage Stats

Coverage Status
Relevant Lines: 15629
Covered Lines: 9958
Line Coverage: 63.71%
Coverage Strength: 7.03 hits per line

💛 - Coveralls

@kallebysantos
Copy link
Copy Markdown
Member Author

WIP: Do not merge until @supabase/server be announced

Comment thread cmd/functions.go Outdated
Comment thread internal/functions/new/templates/index_always_access.ts
Copy link
Copy Markdown
Member

@avallete avallete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments. Otherwise LGTM.

Comment thread internal/functions/new/templates/index_user_access.ts Outdated
Comment thread internal/functions/new/templates/index_user_access.ts Outdated
"imports": {
"@supabase/functions-js": "jsr:@supabase/functions-js@^2"
"@supabase/functions-js": "jsr:@supabase/functions-js@^2",
"@supabase/server": "npm:@supabase/server"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question

Should this be pinned to a major version like for functions-js ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also maybe we use always jsr: or npm: for all imports on these sample codes...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice, but I remember a previous issue where was decided to use the deno.json file to import packages.

Not sure if I should just add it as in-line import directly from jsr: same way I keep for dashboard templates

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it 🤔

The current @supabase/functions-js is in deno.json but still import from jsr: with a fixed major version. Not a deno expert though but it seems that we could do the both that way ?

Also, from our docs, the deno.json approach is the preferred one: https://supabase.com/docs/guides/functions/dependencies#using-denojson-recommended

Which make sense, it's much easier and reliable for us to bundle the functions locally with that approach (I think that's the reason why we made this the recommended way).

Comment thread cmd/functions.go Outdated
@kallebysantos kallebysantos force-pushed the feat-update-functions-template-server-sdk branch from 6b96df4 to b24c3aa Compare April 29, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants