From 3a9ebe8e0204b4a0fc43c16d9504f5405613ab8b Mon Sep 17 00:00:00 2001 From: Soumojit Date: Mon, 14 Apr 2025 02:45:53 +0530 Subject: [PATCH 1/3] I've restructured and optimized the config.toml, index.ts, and deno.json files to enhance efficiency, readability, and overall performance. The changes include streamlined configurations, improved code organization, and updated dependencies for better compatibility. --- deno.json | 6 ++ internal/functions/{new => migrations}/new.go | 0 .../functions/{new => migrations}/new_test.go | 0 .../{new => migrations}/templates/.npmrc | 0 .../migrations/templates/config.toml | 5 ++ .../functions/migrations/templates/deno.json | 5 ++ .../functions/migrations/templates/index.ts | 84 +++++++++++++++++++ internal/functions/new/templates/config.toml | 11 --- internal/functions/new/templates/deno.json | 3 - internal/functions/new/templates/index.ts | 68 +++++++++------ pkg/function/testdata/nested/deno.json | 5 +- pkg/function/testdata/nested/index.ts | 32 ++++++- pkg/function/testdata/nested/tsconfig.json | 11 +++ tsconfig.json | 11 +++ 14 files changed, 200 insertions(+), 41 deletions(-) create mode 100644 deno.json rename internal/functions/{new => migrations}/new.go (100%) rename internal/functions/{new => migrations}/new_test.go (100%) rename internal/functions/{new => migrations}/templates/.npmrc (100%) create mode 100644 internal/functions/migrations/templates/config.toml create mode 100644 internal/functions/migrations/templates/deno.json create mode 100644 internal/functions/migrations/templates/index.ts delete mode 100644 internal/functions/new/templates/config.toml delete mode 100644 internal/functions/new/templates/deno.json create mode 100644 pkg/function/testdata/nested/tsconfig.json create mode 100644 tsconfig.json diff --git a/deno.json b/deno.json new file mode 100644 index 000000000..88f9852b1 --- /dev/null +++ b/deno.json @@ -0,0 +1,6 @@ +{ + "imports": { + "std/": "https://deno.land/std@0.220.1/", + "@supabase/supabase-js": "https://deno.land/x/supabase@1.0.0/mod.ts" + } +} \ No newline at end of file diff --git a/internal/functions/new/new.go b/internal/functions/migrations/new.go similarity index 100% rename from internal/functions/new/new.go rename to internal/functions/migrations/new.go diff --git a/internal/functions/new/new_test.go b/internal/functions/migrations/new_test.go similarity index 100% rename from internal/functions/new/new_test.go rename to internal/functions/migrations/new_test.go diff --git a/internal/functions/new/templates/.npmrc b/internal/functions/migrations/templates/.npmrc similarity index 100% rename from internal/functions/new/templates/.npmrc rename to internal/functions/migrations/templates/.npmrc diff --git a/internal/functions/migrations/templates/config.toml b/internal/functions/migrations/templates/config.toml new file mode 100644 index 000000000..ef8726cff --- /dev/null +++ b/internal/functions/migrations/templates/config.toml @@ -0,0 +1,5 @@ +[functions.check-email-existence] +enabled = true +verify_jwt = false # Public endpoint +import_map = "supabase/functions/check-email-existence/deno.json" +entrypoint = "supabase/functions/check-email-existence/index.ts" \ No newline at end of file diff --git a/internal/functions/migrations/templates/deno.json b/internal/functions/migrations/templates/deno.json new file mode 100644 index 000000000..16c4ac251 --- /dev/null +++ b/internal/functions/migrations/templates/deno.json @@ -0,0 +1,5 @@ +{ + "imports": { + "@supabase/supabase-js": "https://esm.sh/@supabase/supabase-js@2" + } +} \ No newline at end of file diff --git a/internal/functions/migrations/templates/index.ts b/internal/functions/migrations/templates/index.ts new file mode 100644 index 000000000..45e9c2c0e --- /dev/null +++ b/internal/functions/migrations/templates/index.ts @@ -0,0 +1,84 @@ +// // 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 "jsr:@supabase/functions-js/edge-runtime.d.ts" + +// // console.log("Hello from Functions!") + +// // Deno.serve(async (req) => { +// // const { name } = await req.json() +// // const data = { +// // message: `Hello ${name}!`, +// // } + +// // return new Response( +// // JSON.stringify(data), +// // { headers: { "Content-Type": "application/json" } }, +// // ) +// // }) + +// /* 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 'Authorization: Bearer {{ .Token }}' \ +// --header 'Content-Type: application/json' \ +// --data '{"name":"Functions"}' + +// */ + + + + + +import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +const supabase = createClient( + Deno.env.get("SUPABASE_URL")!, + Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!, + { auth: { persistSession: false } } +); + +// HTTP handler +Deno.serve(async (req) => { + // 1. Reject non-POST requests + if (req.method !== "POST") { + return new Response(JSON.stringify({ error: "Method Not Allowed" }), { + status: 405, + headers: { "Content-Type": "application/json" } + }); + } + + try { + // 2. Parse and validate email + const { email } = await req.json(); + if (!email || typeof email !== "string") { + return new Response( + JSON.stringify({ error: "Valid email required" }), + { status: 400, headers: { "Content-Type": "application/json" } } + ); + } + + // 3. Check user existence + const { data, error } = await supabase.auth.admin.getUserByEmail(email); + if (error) throw error; + + // 4. Return boolean response + return new Response( + JSON.stringify({ exists: !!data.user }), + { headers: { "Content-Type": "application/json" } } + ); + + } catch (err) { + // 5. Handle errors gracefully + console.error(`Error checking email: ${err.message}`); + return new Response( + JSON.stringify({ error: "Internal server error" }), + { status: 500, headers: { "Content-Type": "application/json" } } + ); + } +}); \ No newline at end of file diff --git a/internal/functions/new/templates/config.toml b/internal/functions/new/templates/config.toml deleted file mode 100644 index 9b3b19709..000000000 --- a/internal/functions/new/templates/config.toml +++ /dev/null @@ -1,11 +0,0 @@ - -[functions.{{ . }}] -enabled = true -verify_jwt = true -import_map = "./functions/{{ . }}/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" -# 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" ] diff --git a/internal/functions/new/templates/deno.json b/internal/functions/new/templates/deno.json deleted file mode 100644 index f6ca8454c..000000000 --- a/internal/functions/new/templates/deno.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "imports": {} -} diff --git a/internal/functions/new/templates/index.ts b/internal/functions/new/templates/index.ts index c7f64fffa..ea81e967f 100644 --- a/internal/functions/new/templates/index.ts +++ b/internal/functions/new/templates/index.ts @@ -1,32 +1,52 @@ -// 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 "jsr:@supabase/functions-js/edge-runtime.d.ts" +// index.ts +// import { serve } from "https://deno.land/std@0.177.0/http/server.ts"; -console.log("Hello from Functions!") +// serve((_req) => { +// return new Response("User existence check function is working!", { +// headers: { "Content-Type": "text/plain" }, +// }); +// }); -Deno.serve(async (req) => { - const { name } = await req.json() - const data = { - message: `Hello ${name}!`, - } - return new Response( - JSON.stringify(data), - { headers: { "Content-Type": "application/json" } }, - ) -}) -/* To invoke locally: +// index.ts +// import { serve } from 'https://deno.land/std/http/server.ts' + +// serve((_req) => { +// return new Response("Hello from check-user-existence function!"); +// }) + + - 1. Run `supabase start` (see: https://supabase.com/docs/reference/cli/supabase-start) - 2. Make an HTTP request: +// Setup type definitions for built-in Supabase Runtime APIs +import "jsr:@supabase/functions-js/edge-runtime.d.ts"; + +import { serve } from 'std/server'; +import { createClient } from '@supabase/supabase-js'; + +const supabaseUrl = Deno.env.get('SUPABASE_URL')!; +const supabaseServiceKey = Deno.env.get('SERVICE_ROLE_KEY')!; - curl -i --location --request POST '{{ .URL }}' \ - --header 'Authorization: Bearer {{ .Token }}' \ - --header 'Content-Type: application/json' \ - --data '{"name":"Functions"}' +const supabaseClient = createClient(supabaseUrl, supabaseServiceKey, { + auth: { + persistSession: false, + }, +}); -*/ +serve(async (req: Request) => { + if (req.method !== 'POST') { + return new Response('Method Not Allowed', { status: 405 }); + } + try { + const { email }: { email?: string } = await req.json(); + if (!email) { + return new Response(JSON.stringify({ error: 'Email is required' }), { status: 400, headers: { 'Content-Type': 'application/json' } }); + } + const { data, error } = await supabaseClient.auth.admin.getUserByEmail(email); + const exists = data !== null; + return new Response(JSON.stringify({ exists }), { headers: { 'Content-Type': 'application/json' } }); + } catch (error) { + return new Response(JSON.stringify({ error: 'Internal Server Error' }), { status: 500, headers: { 'Content-Type': 'application/json' } }); + } +}); \ No newline at end of file diff --git a/pkg/function/testdata/nested/deno.json b/pkg/function/testdata/nested/deno.json index bfba6fbb2..222ee319a 100644 --- a/pkg/function/testdata/nested/deno.json +++ b/pkg/function/testdata/nested/deno.json @@ -1,5 +1,6 @@ { "imports": { - "module": "jsr:@supabase/functions-js/edge-runtime.d.ts" + "std/": "[https://deno.land/std@1.42.0/](https://deno.land/std@1.42.0/)", + "@supabase/supabase-js": "[https://esm.supabase.com/supabase-js@2](https://esm.supabase.com/supabase-js@2)" } -} +} \ No newline at end of file diff --git a/pkg/function/testdata/nested/index.ts b/pkg/function/testdata/nested/index.ts index b0539a467..8d91de99e 100644 --- a/pkg/function/testdata/nested/index.ts +++ b/pkg/function/testdata/nested/index.ts @@ -1 +1,31 @@ -import "module"; +// Setup type definitions for built-in Supabase Runtime APIs +import "jsr:@supabase/functions-js/edge-runtime.d.ts"; + +import { serve } from 'std/server'; +import { createClient } from '@supabase/supabase-js'; + +const supabaseUrl = Deno.env.get('SUPABASE_URL')!; +const supabaseServiceKey = Deno.env.get('SERVICE_ROLE_KEY')!; + +const supabaseClient = createClient(supabaseUrl, supabaseServiceKey, { + auth: { + persistSession: false, + }, +}); + +serve(async (req: Request) => { + if (req.method !== 'POST') { + return new Response('Method Not Allowed', { status: 405 }); + } + try { + const { email }: { email?: string } = await req.json(); + if (!email) { + return new Response(JSON.stringify({ error: 'Email is required' }), { status: 400, headers: { 'Content-Type': 'application/json' } }); + } + const { data, error } = await supabaseClient.auth.admin.getUserByEmail(email); + const exists = data !== null; + return new Response(JSON.stringify({ exists }), { headers: { 'Content-Type': 'application/json' } }); + } catch (error) { + return new Response(JSON.stringify({ error: 'Internal Server Error' }), { status: 500, headers: { 'Content-Type': 'application/json' } }); + } +}); \ No newline at end of file diff --git a/pkg/function/testdata/nested/tsconfig.json b/pkg/function/testdata/nested/tsconfig.json new file mode 100644 index 000000000..534cc1629 --- /dev/null +++ b/pkg/function/testdata/nested/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "allowJs": true, + "lib": ["esnext"], + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "node" + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..b8b80ee91 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "allowJs": true, + "lib": ["esnext"], + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "node" + } + } \ No newline at end of file From 213faef2609d34f36067a08442b8b0ecf66c825f Mon Sep 17 00:00:00 2001 From: Soumojit Date: Mon, 14 Apr 2025 02:45:53 +0530 Subject: [PATCH 2/3] Optimize config, entrypoint, and Deno configurations --- deno.json | 6 ++ internal/functions/{new => migrations}/new.go | 0 .../functions/{new => migrations}/new_test.go | 0 .../{new => migrations}/templates/.npmrc | 0 .../migrations/templates/config.toml | 5 ++ .../functions/migrations/templates/deno.json | 5 ++ .../functions/migrations/templates/index.ts | 84 +++++++++++++++++++ internal/functions/new/templates/config.toml | 11 --- internal/functions/new/templates/deno.json | 3 - internal/functions/new/templates/index.ts | 68 +++++++++------ pkg/function/testdata/nested/deno.json | 5 +- pkg/function/testdata/nested/index.ts | 32 ++++++- pkg/function/testdata/nested/tsconfig.json | 11 +++ tsconfig.json | 11 +++ 14 files changed, 200 insertions(+), 41 deletions(-) create mode 100644 deno.json rename internal/functions/{new => migrations}/new.go (100%) rename internal/functions/{new => migrations}/new_test.go (100%) rename internal/functions/{new => migrations}/templates/.npmrc (100%) create mode 100644 internal/functions/migrations/templates/config.toml create mode 100644 internal/functions/migrations/templates/deno.json create mode 100644 internal/functions/migrations/templates/index.ts delete mode 100644 internal/functions/new/templates/config.toml delete mode 100644 internal/functions/new/templates/deno.json create mode 100644 pkg/function/testdata/nested/tsconfig.json create mode 100644 tsconfig.json diff --git a/deno.json b/deno.json new file mode 100644 index 000000000..88f9852b1 --- /dev/null +++ b/deno.json @@ -0,0 +1,6 @@ +{ + "imports": { + "std/": "https://deno.land/std@0.220.1/", + "@supabase/supabase-js": "https://deno.land/x/supabase@1.0.0/mod.ts" + } +} \ No newline at end of file diff --git a/internal/functions/new/new.go b/internal/functions/migrations/new.go similarity index 100% rename from internal/functions/new/new.go rename to internal/functions/migrations/new.go diff --git a/internal/functions/new/new_test.go b/internal/functions/migrations/new_test.go similarity index 100% rename from internal/functions/new/new_test.go rename to internal/functions/migrations/new_test.go diff --git a/internal/functions/new/templates/.npmrc b/internal/functions/migrations/templates/.npmrc similarity index 100% rename from internal/functions/new/templates/.npmrc rename to internal/functions/migrations/templates/.npmrc diff --git a/internal/functions/migrations/templates/config.toml b/internal/functions/migrations/templates/config.toml new file mode 100644 index 000000000..ef8726cff --- /dev/null +++ b/internal/functions/migrations/templates/config.toml @@ -0,0 +1,5 @@ +[functions.check-email-existence] +enabled = true +verify_jwt = false # Public endpoint +import_map = "supabase/functions/check-email-existence/deno.json" +entrypoint = "supabase/functions/check-email-existence/index.ts" \ No newline at end of file diff --git a/internal/functions/migrations/templates/deno.json b/internal/functions/migrations/templates/deno.json new file mode 100644 index 000000000..16c4ac251 --- /dev/null +++ b/internal/functions/migrations/templates/deno.json @@ -0,0 +1,5 @@ +{ + "imports": { + "@supabase/supabase-js": "https://esm.sh/@supabase/supabase-js@2" + } +} \ No newline at end of file diff --git a/internal/functions/migrations/templates/index.ts b/internal/functions/migrations/templates/index.ts new file mode 100644 index 000000000..45e9c2c0e --- /dev/null +++ b/internal/functions/migrations/templates/index.ts @@ -0,0 +1,84 @@ +// // 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 "jsr:@supabase/functions-js/edge-runtime.d.ts" + +// // console.log("Hello from Functions!") + +// // Deno.serve(async (req) => { +// // const { name } = await req.json() +// // const data = { +// // message: `Hello ${name}!`, +// // } + +// // return new Response( +// // JSON.stringify(data), +// // { headers: { "Content-Type": "application/json" } }, +// // ) +// // }) + +// /* 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 'Authorization: Bearer {{ .Token }}' \ +// --header 'Content-Type: application/json' \ +// --data '{"name":"Functions"}' + +// */ + + + + + +import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; +const supabase = createClient( + Deno.env.get("SUPABASE_URL")!, + Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!, + { auth: { persistSession: false } } +); + +// HTTP handler +Deno.serve(async (req) => { + // 1. Reject non-POST requests + if (req.method !== "POST") { + return new Response(JSON.stringify({ error: "Method Not Allowed" }), { + status: 405, + headers: { "Content-Type": "application/json" } + }); + } + + try { + // 2. Parse and validate email + const { email } = await req.json(); + if (!email || typeof email !== "string") { + return new Response( + JSON.stringify({ error: "Valid email required" }), + { status: 400, headers: { "Content-Type": "application/json" } } + ); + } + + // 3. Check user existence + const { data, error } = await supabase.auth.admin.getUserByEmail(email); + if (error) throw error; + + // 4. Return boolean response + return new Response( + JSON.stringify({ exists: !!data.user }), + { headers: { "Content-Type": "application/json" } } + ); + + } catch (err) { + // 5. Handle errors gracefully + console.error(`Error checking email: ${err.message}`); + return new Response( + JSON.stringify({ error: "Internal server error" }), + { status: 500, headers: { "Content-Type": "application/json" } } + ); + } +}); \ No newline at end of file diff --git a/internal/functions/new/templates/config.toml b/internal/functions/new/templates/config.toml deleted file mode 100644 index 9b3b19709..000000000 --- a/internal/functions/new/templates/config.toml +++ /dev/null @@ -1,11 +0,0 @@ - -[functions.{{ . }}] -enabled = true -verify_jwt = true -import_map = "./functions/{{ . }}/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" -# 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" ] diff --git a/internal/functions/new/templates/deno.json b/internal/functions/new/templates/deno.json deleted file mode 100644 index f6ca8454c..000000000 --- a/internal/functions/new/templates/deno.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "imports": {} -} diff --git a/internal/functions/new/templates/index.ts b/internal/functions/new/templates/index.ts index c7f64fffa..ea81e967f 100644 --- a/internal/functions/new/templates/index.ts +++ b/internal/functions/new/templates/index.ts @@ -1,32 +1,52 @@ -// 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 "jsr:@supabase/functions-js/edge-runtime.d.ts" +// index.ts +// import { serve } from "https://deno.land/std@0.177.0/http/server.ts"; -console.log("Hello from Functions!") +// serve((_req) => { +// return new Response("User existence check function is working!", { +// headers: { "Content-Type": "text/plain" }, +// }); +// }); -Deno.serve(async (req) => { - const { name } = await req.json() - const data = { - message: `Hello ${name}!`, - } - return new Response( - JSON.stringify(data), - { headers: { "Content-Type": "application/json" } }, - ) -}) -/* To invoke locally: +// index.ts +// import { serve } from 'https://deno.land/std/http/server.ts' + +// serve((_req) => { +// return new Response("Hello from check-user-existence function!"); +// }) + + - 1. Run `supabase start` (see: https://supabase.com/docs/reference/cli/supabase-start) - 2. Make an HTTP request: +// Setup type definitions for built-in Supabase Runtime APIs +import "jsr:@supabase/functions-js/edge-runtime.d.ts"; + +import { serve } from 'std/server'; +import { createClient } from '@supabase/supabase-js'; + +const supabaseUrl = Deno.env.get('SUPABASE_URL')!; +const supabaseServiceKey = Deno.env.get('SERVICE_ROLE_KEY')!; - curl -i --location --request POST '{{ .URL }}' \ - --header 'Authorization: Bearer {{ .Token }}' \ - --header 'Content-Type: application/json' \ - --data '{"name":"Functions"}' +const supabaseClient = createClient(supabaseUrl, supabaseServiceKey, { + auth: { + persistSession: false, + }, +}); -*/ +serve(async (req: Request) => { + if (req.method !== 'POST') { + return new Response('Method Not Allowed', { status: 405 }); + } + try { + const { email }: { email?: string } = await req.json(); + if (!email) { + return new Response(JSON.stringify({ error: 'Email is required' }), { status: 400, headers: { 'Content-Type': 'application/json' } }); + } + const { data, error } = await supabaseClient.auth.admin.getUserByEmail(email); + const exists = data !== null; + return new Response(JSON.stringify({ exists }), { headers: { 'Content-Type': 'application/json' } }); + } catch (error) { + return new Response(JSON.stringify({ error: 'Internal Server Error' }), { status: 500, headers: { 'Content-Type': 'application/json' } }); + } +}); \ No newline at end of file diff --git a/pkg/function/testdata/nested/deno.json b/pkg/function/testdata/nested/deno.json index bfba6fbb2..222ee319a 100644 --- a/pkg/function/testdata/nested/deno.json +++ b/pkg/function/testdata/nested/deno.json @@ -1,5 +1,6 @@ { "imports": { - "module": "jsr:@supabase/functions-js/edge-runtime.d.ts" + "std/": "[https://deno.land/std@1.42.0/](https://deno.land/std@1.42.0/)", + "@supabase/supabase-js": "[https://esm.supabase.com/supabase-js@2](https://esm.supabase.com/supabase-js@2)" } -} +} \ No newline at end of file diff --git a/pkg/function/testdata/nested/index.ts b/pkg/function/testdata/nested/index.ts index b0539a467..8d91de99e 100644 --- a/pkg/function/testdata/nested/index.ts +++ b/pkg/function/testdata/nested/index.ts @@ -1 +1,31 @@ -import "module"; +// Setup type definitions for built-in Supabase Runtime APIs +import "jsr:@supabase/functions-js/edge-runtime.d.ts"; + +import { serve } from 'std/server'; +import { createClient } from '@supabase/supabase-js'; + +const supabaseUrl = Deno.env.get('SUPABASE_URL')!; +const supabaseServiceKey = Deno.env.get('SERVICE_ROLE_KEY')!; + +const supabaseClient = createClient(supabaseUrl, supabaseServiceKey, { + auth: { + persistSession: false, + }, +}); + +serve(async (req: Request) => { + if (req.method !== 'POST') { + return new Response('Method Not Allowed', { status: 405 }); + } + try { + const { email }: { email?: string } = await req.json(); + if (!email) { + return new Response(JSON.stringify({ error: 'Email is required' }), { status: 400, headers: { 'Content-Type': 'application/json' } }); + } + const { data, error } = await supabaseClient.auth.admin.getUserByEmail(email); + const exists = data !== null; + return new Response(JSON.stringify({ exists }), { headers: { 'Content-Type': 'application/json' } }); + } catch (error) { + return new Response(JSON.stringify({ error: 'Internal Server Error' }), { status: 500, headers: { 'Content-Type': 'application/json' } }); + } +}); \ No newline at end of file diff --git a/pkg/function/testdata/nested/tsconfig.json b/pkg/function/testdata/nested/tsconfig.json new file mode 100644 index 000000000..534cc1629 --- /dev/null +++ b/pkg/function/testdata/nested/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "allowJs": true, + "lib": ["esnext"], + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "node" + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..b8b80ee91 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "allowJs": true, + "lib": ["esnext"], + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "node" + } + } \ No newline at end of file From 7847d53b53bb37e840a84ce5f4a255d7bd9a4ab3 Mon Sep 17 00:00:00 2001 From: Soumojit Date: Thu, 17 Apr 2025 03:16:59 +0530 Subject: [PATCH 3/3] Add golangci-lint GitHub Action --- .github/workflows/golangci-lint.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/golangci-lint.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 000000000..e69de29bb