Files
suanming/create_function_templates.ps1

71 lines
1.9 KiB
PowerShell

# 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!"