mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:31:13 -05:00
Update plan with remaining phases
This commit is contained in:
@@ -3,7 +3,7 @@ import { serve } from "https://deno.land/std@0.190.0/http/server.ts";
|
||||
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4";
|
||||
import { validateEntityData, validateEntityDataStrict } from "./validation.ts";
|
||||
import { createErrorResponse } from "../_shared/errorSanitizer.ts";
|
||||
import { edgeLogger } from "../_shared/logger.ts";
|
||||
import { edgeLogger, startRequest, endRequest } from "../_shared/logger.ts";
|
||||
|
||||
const corsHeaders = {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
@@ -47,17 +47,33 @@ const RIDE_MODEL_FIELDS = [
|
||||
];
|
||||
|
||||
serve(async (req) => {
|
||||
const tracking = startRequest(); // Start request tracking
|
||||
|
||||
if (req.method === 'OPTIONS') {
|
||||
return new Response(null, { headers: corsHeaders });
|
||||
}
|
||||
|
||||
try {
|
||||
edgeLogger.info('Processing selective approval request', {
|
||||
requestId: tracking.requestId,
|
||||
traceId: tracking.traceId
|
||||
});
|
||||
|
||||
// Verify authentication first with a client that respects RLS
|
||||
const authHeader = req.headers.get('Authorization');
|
||||
if (!authHeader) {
|
||||
const duration = endRequest(tracking);
|
||||
edgeLogger.warn('Authentication missing', { requestId: tracking.requestId, duration });
|
||||
return new Response(
|
||||
JSON.stringify({ error: 'Authentication required. Please log in.' }),
|
||||
{ status: 401, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
|
||||
JSON.stringify({ error: 'Authentication required. Please log in.', requestId: tracking.requestId }),
|
||||
{
|
||||
status: 401,
|
||||
headers: {
|
||||
...corsHeaders,
|
||||
'Content-Type': 'application/json',
|
||||
'X-Request-ID': tracking.requestId
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user