Implement Phase 2 improvements

Implement slug uniqueness constraints, foreign key validation, and rate limiting.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-06 23:59:48 +00:00
parent f3b21260e7
commit 13c6e20f11
2 changed files with 213 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2.57.4';
import { corsHeaders } from './cors.ts';
import { rateLimiters, withRateLimit } from '../_shared/rateLimiter.ts';
const SUPABASE_URL = Deno.env.get('SUPABASE_URL') || 'https://api.thrillwiki.com';
const SUPABASE_ANON_KEY = Deno.env.get('SUPABASE_ANON_KEY')!;
@@ -11,7 +12,8 @@ interface ApprovalRequest {
idempotencyKey: string;
}
serve(async (req) => {
// Main handler function
const handler = async (req: Request) => {
// Handle CORS preflight requests
if (req.method === 'OPTIONS') {
return new Response(null, {
@@ -278,4 +280,7 @@ serve(async (req) => {
}
);
}
});
};
// Apply rate limiting: 10 requests per minute per IP (standard tier)
serve(withRateLimit(handler, rateLimiters.standard, corsHeaders));