import { listenAndServe } from "https://deno.land/[email protected]/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);
Comments
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎