mirror of
https://github.com/patdelphi/suanming.git
synced 2026-03-11 19:04:42 +08:00
feat: 保存当前Supabase版本,准备进行本地化改造
This commit is contained in:
71
create_function_templates.ps1
Normal file
71
create_function_templates.ps1
Normal file
@@ -0,0 +1,71 @@
|
||||
# PowerShell script to create template files for all remaining Edge Functions
|
||||
|
||||
$functions = @(
|
||||
'numerology-analysis',
|
||||
'reading-history',
|
||||
'yijing-analyzer',
|
||||
'bazi-analysis',
|
||||
'ziwei-analysis',
|
||||
'yijing-analysis',
|
||||
'create-user-simple',
|
||||
'create-admin-user',
|
||||
'custom-auth',
|
||||
'profile-manager',
|
||||
'wuxing-analysis',
|
||||
'bazi-detail-analysis',
|
||||
'bazi-wuxing-analysis',
|
||||
'bazi-details'
|
||||
)
|
||||
|
||||
$template = @'
|
||||
// Supabase Edge Function: {0}
|
||||
// TODO: Copy the actual code from Supabase Dashboard
|
||||
|
||||
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts'
|
||||
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
|
||||
|
||||
const corsHeaders = {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
|
||||
}
|
||||
|
||||
serve(async (req) => {
|
||||
// Handle CORS preflight requests
|
||||
if (req.method === 'OPTIONS') {
|
||||
return new Response('ok', { headers: corsHeaders })
|
||||
}
|
||||
|
||||
try {
|
||||
// TODO: Replace with actual implementation from Dashboard
|
||||
return new Response(
|
||||
JSON.stringify({ message: '{0} function - replace with actual code' }),
|
||||
{
|
||||
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
|
||||
}
|
||||
)
|
||||
} catch (error) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: error.message }),
|
||||
{
|
||||
status: 500,
|
||||
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
'@
|
||||
|
||||
foreach ($func in $functions) {
|
||||
$functionName = $func -replace '-', ' ' | ForEach-Object { (Get-Culture).TextInfo.ToTitleCase($_) }
|
||||
$content = $template -f $functionName, $func
|
||||
$filePath = "supabase\functions\$func\index.ts"
|
||||
|
||||
if (!(Test-Path $filePath)) {
|
||||
$content | Out-File -FilePath $filePath -Encoding UTF8
|
||||
Write-Host "Created: $filePath"
|
||||
} else {
|
||||
Write-Host "Already exists: $filePath"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "All function templates created successfully!"
|
||||
Reference in New Issue
Block a user