import { listenAndServe } from "https://deno.land/std@0.111.0/http/server.ts"; async function handler(req) { const apiKey = Deno.env.get("API_KEY"); const secret = Deno.env.get("API_SECRET"); if (secret !== req.headers.get("X-Secret")) { return new Response("Hello world", { status: 200 }); } return await fetch("https://api.openai.com/v1/engines/code-cushman-001/completions", { headers: { ...req.headers, "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, method: req.method, body: req.body, }); } console.log("Listening on http://localhost:8080"); await listenAndServe(":8080", handler);